Introduction to R
- 147Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
Why is R considered an important language for data science?
147 questions
- 1
Why is R considered an important language for data science?
Model answer
R is widely used by data-mining professionals and is especially designed for statistical computing and data analysis.
Explanation
The content presents R as a leading data-science tool and notes that it ranked above Python in a survey of data-mining experts.
- 2
What are three advantages of R over expensive proprietary software?
Model answer
R is free, open source, and supported by a large community with many freely available packages.
Explanation
The content emphasizes that comparable proprietary software may cost thousands of dollars per year, while R can be freely downloaded and extended.
- 3
What does it mean that R is optimized for vector operations?
Model answer
R can operate on an entire vector, row, or table of data without requiring the user to write explicit loops for every element.
Explanation
Vectorization reduces repetitive programming and makes many data operations more efficient and convenient.
- 4
How does the R community support users?
Model answer
The community provides help, examples, documentation, and continuing package developments.
Explanation
A large, supportive community makes it easier to find solutions and learn new techniques.
- 5
What is the significance of R having more than 9,000 contributed packages?
Model answer
The packages add specialized functionality, making it possible to perform a very wide range of data-analysis tasks.
Explanation
Packages extend R beyond its built-in capabilities and allow users to accomplish tasks that would otherwise require writing much more code.
- 6
Where can a user download the R programming language?
Model answer
R can be downloaded from the R Project website through the Comprehensive R Archive Network, or CRAN.
Explanation
The installation process begins at the R Project website and directs users to CRAN mirrors.
- 7
Why is the cloud-based CRAN mirror a convenient download choice?
Model answer
It automatically directs the user to a suitable mirror based on the user's location.
Explanation
Using the cloud option avoids requiring users to choose a specific mirror manually.
- 8
How does R installation differ across operating systems?
Model answer
Mac users download the package installer, Windows users typically choose the base installer, and Linux users generally follow distribution-specific installation procedures.
Explanation
The download page provides operating-system-specific installers and instructions.
- 9
What is an R source file?
Model answer
An R source file is a script containing R code and normally has the
.rfile extension.Explanation
The course files include scripts that can be opened and run in R or RStudio.
- 10
What is the purpose of the course data-files folder?
Model answer
It contains data files used in the examples and exercises.
Explanation
The downloaded files include scripts and a separate folder containing datasets.
- 11
What are the two main windows in the basic R application?
Model answer
The source or script window is used for programming, and the console window displays output and accepts commands.
Explanation
The basic R environment separates code editing from command output.
- 12
What does a line beginning with a pound sign represent in R?
Model answer
It is a comment and is not executed as code.
Explanation
Comments document code without affecting the program's operations.
- 13
How can a user run a line of code from the R script window?
Model answer
The user places the cursor on the line and presses Command-Enter on a Mac or Control-Enter on Windows.
Explanation
This shortcut sends the selected line from the script window to the console for execution.
- 14
What information does the
irisdataset contain?Model answer
It contains sepal and petal measurements for three species of iris flowers.
Explanation
The dataset includes sepal length, sepal width, petal length, petal width, and species.
- 15
What does the
headfunction typically show?Model answer
It displays the first six rows of a dataset.
Explanation
The function provides a quick look at the structure and initial observations of a dataset.
- 16
What does the basic
summaryfunction provide for a dataset?Model answer
It provides descriptive information such as quartiles, means, minimums, maximums, and category frequencies.
Explanation
The output depends on the variable type: quantitative variables receive numerical summaries, while categorical variables receive counts.
- 17
What is RStudio, and how does it differ from R?
Model answer
RStudio is an additional development environment that provides a more organized and convenient interface for working with R; it does not replace the R installation.
Explanation
RStudio runs on top of R and makes coding, output management, and navigation easier.
- 18
How does RStudio standardize keyboard commands?
Model answer
It provides consistent shortcuts for common operations across Mac, Windows, and Linux.
Explanation
The underlying operating systems may use different commands, but RStudio creates a consistent interface.
- 19
What are the main panes in the RStudio interface?
Model answer
They include the source window, console, environment pane, and a pane for plots and other information.
Explanation
RStudio organizes programming, output, saved variables, and visualizations in one window.
- 20
How can RStudio panes be customized?
Model answer
Users can resize panes by dragging dividers and rearrange the interface through its settings.
Explanation
RStudio is a flexible environment that allows users to adjust the workspace to their preferences.
- 21
What is an R package?
Model answer
An R package is a bundle of code that adds functions and capabilities to R.
Explanation
Packages extend the language and allow users to perform specialized analyses or tasks.
- 22
What is the difference between a base package and a contributed package?
Model answer
Base packages are installed with R but may not be loaded automatically, whereas contributed packages must usually be downloaded, installed, and loaded separately.
Explanation
Separating installation from loading helps control memory use and makes optional functionality available when needed.
- 23
What is CRAN's role in the R package ecosystem?
Model answer
CRAN is an official repository that provides R packages along with their documentation.
Explanation
Users can browse packages directly or organize them through CRAN task views.
- 24
What is the purpose of CRAN task views?
Model answer
They organize packages by subject area, such as Bayesian inference or computational physics.
Explanation
Task views help users find packages relevant to a particular field or type of analysis.
- 25
How does CRANtastic help users find packages?
Model answer
It lists popular and recently updated packages, then redirects users to CRAN for downloading.
Explanation
CRANtastic is primarily a package-discovery and information site rather than the actual download repository.
- 26
How can GitHub be used with R packages?
Model answer
R packages can be obtained from GitHub through a process separate from downloading them from CRAN.
Explanation
GitHub is an alternative source, especially for packages or developments not obtained through the standard CRAN process.
- 27
Match the following packages with their primary purposes:
dplyr,tidyr,stringr,lubridate,httr,ggplot2,shiny,rio, andrmarkdown.Model answer
dplyrmanipulates data frames,tidyrcleans data,stringrhandles text,lubridatehandles dates,httrworks with website data,ggplot2creates graphics,shinycreates interactive applications,rioimports and exports data, andrmarkdowncreates rich documents.Explanation
These contributed packages provide specialized tools for common data-science tasks.
- 28
What is the purpose of the
pacmanpackage?Model answer
It helps manage packages, including installing, loading, and unloading them.
Explanation
Its functions can simplify package management compared with performing each operation separately.
- 29
What is the difference between installing and loading an R package?
Model answer
Installing makes a package available on the computer, while loading makes its functions accessible in the current R session.
Explanation
A package may be installed but unavailable for use until it is loaded.
- 30
How do
requireandlibrarydiffer when loading a package?Model answer
requireprovides a confirmation message when it loads a package, whereaslibraryloads it without displaying that confirmation.Explanation
Both functions make an installed package available to the current session.
- 31
How can contributed packages be unloaded with
pacman?Model answer
The
p_unload_allfunction unloads all add-on or contributed packages.Explanation
Base packages such as
datasetsare handled separately with the standarddetachcommand. - 32
What is the default
plotcommand used for?Model answer
It creates basic visualizations and adapts the graph to the number and types of variables supplied.
Explanation
The command can produce different graphical forms without the user explicitly specifying the chart type.
- 33
What graph does
plottypically produce for a single categorical variable?Model answer
It produces a bar chart showing the frequency of each category.
Explanation
For example, plotting iris species produces bars for setosa, versicolor, and virginica.
- 34
What does the
iris$speciesnotation specify?Model answer
It selects the
speciesvariable from theirisdata frame.Explanation
The dollar sign is used to access a named variable within a data frame.
- 35
What graph does the default
plotcommand typically produce for one quantitative variable?Model answer
It produces a scatterplot with the observation index on the horizontal axis and the quantitative variable on the vertical axis.
Explanation
Although the result displays the variable's distribution, the index axis may not be substantively useful.
- 36
What graph does
plottypically produce for one categorical and one quantitative variable?Model answer
It typically produces a box plot comparing the quantitative distributions across categories.
Explanation
R recognizes the variable types and chooses a suitable comparison graph.
- 37
What graph does
plottypically produce for two quantitative variables?Model answer
It produces a scatterplot showing their association.
Explanation
For example, petal length and petal width show a strong positive association in the iris data.
- 38
What does plotting an entire data frame usually produce?
Model answer
It produces a matrix of plots for the quantitative variables and graphical summaries for other variables.
Explanation
This provides a quick, holistic view when the dataset does not contain too many variables.
- 39
What do the
col,pch,main,xlab, andylabplotting arguments control?Model answer
colcontrols color,pchcontrols point shape,mainadds a title, andxlabandylablabel the horizontal and vertical axes.Explanation
These options improve the readability and presentation quality of basic plots.
- 40
How can the
plotcommand graph a mathematical function?Model answer
A function such as cosine, an exponential function, or a normal-density function can be supplied over a specified interval.
Explanation
The command is not limited to observed data; it can also display mathematical curves.
- 41
What do
lwdandaddcontrol in a plot?Model answer
lwdcontrols line width, whileaddplaces a new curve or graph on an existing plot.Explanation
These options are useful for emphasizing curves and overlaying related information.
- 42
What type of variable is best represented by a bar chart?
Model answer
A categorical variable is best represented by a bar chart.
Explanation
Bar charts display counts or frequencies for distinct categories.
- 43
Why must raw case-level data often be summarized before making a bar chart?
Model answer
A bar chart requires category frequencies, so the raw observations must first be converted into a summary table of counts.
Explanation
Plotting the raw cylinder values in
mtcarswould display one value per case rather than the number of cars in each cylinder category. - 44
What does the
tablefunction do when preparing categorical data?Model answer
It counts the observations in each category and creates a frequency table.
Explanation
The resulting table can then be supplied to
barplotto produce the intended bar chart. - 45
What type of variable is best represented by a histogram?
Model answer
A histogram is best used for a quantitative, scaled, interval, or ratio-level variable.
Explanation
Histograms show how numerical observations are distributed across intervals.
- 46
What features should be examined in a histogram?
Model answer
The analyst should examine shape, symmetry, skewness, modality, gaps, and outliers.
Explanation
These features reveal important characteristics that may affect later analyses.
- 47
What does the vertical axis of a basic histogram usually represent?
Model answer
It usually represents the frequency or count of observations in each interval.
Explanation
For example, the height of a bar indicates how many observations fall within that range.
- 48
Why are outliers important when examining a histogram?
Model answer
Outliers can distort subsequent statistical analyses and may require further investigation.
Explanation
Unusual observations can affect summaries, models, and interpretations.
- 49
What is the purpose of arranging histograms in multiple rows for different groups?
Model answer
It allows the distributions of the same quantitative variable to be compared separately across groups.
Explanation
In the iris example, separate histograms reveal that setosa has lower petal measurements while the other species overlap more.
- 50
What are small multiples?
Model answer
Small multiples are multiple versions of the same graph displayed on the same scale for different groups or conditions.
Explanation
Using a common scale makes visual comparisons across groups easier and more reliable.
- 51
Why should graphical parameters be restored after creating customized multiple plots?
Model answer
They should be restored so that later graphs return to the standard layout rather than inheriting the temporary settings.
Explanation
Changing the plotting layout affects subsequent graphics until the parameters are changed back.
- 52
What is the canonical purpose of a scatterplot?
Model answer
A scatterplot visualizes the association between two quantitative variables.
Explanation
Each point represents one observation located by its values on the two variables.
- 53
What should be examined to determine whether a scatterplot shows a linear association?
Model answer
The analyst should determine whether the points can be reasonably described by a straight line.
Explanation
Many statistical procedures assume linearity, so departures from a straight-line pattern matter.
- 54
What is heteroscedasticity?
Model answer
Heteroscedasticity is a substantially changing spread of scores across the range of the predictor, often appearing as a fan-shaped pattern.
Explanation
Unequal spread can complicate regression and other analyses.
- 55
Why should outliers be examined in a scatterplot?
Model answer
An unusual point or unusual combination of values can substantially alter the apparent association and later interpretations.
Explanation
Scatterplots can reveal influential observations that may not be obvious from numerical summaries alone.
- 56
What relationship between weight and fuel efficiency is shown in the
mtcarsexample?Model answer
The relationship is strongly negative: heavier cars tend to have lower miles per gallon.
Explanation
The scatterplot shows a strong downhill pattern from lighter, more efficient cars to heavier, less efficient cars.
- 57
Why should univariate distributions be examined before studying an association?
Model answer
Examining each variable separately helps identify its shape, unusual values, and potential problems before interpreting their joint relationship.
Explanation
The individual histograms provide context for understanding the scatterplot.
- 58
Why might an analyst overlay plots?
Model answer
Overlaying plots increases information density and can provide more insight in the same amount of space.
Explanation
Several complementary views can reveal different aspects of the same data.
- 59
What is the main risk of overlaying too many plots?
Model answer
The graphic can become cognitively overwhelming and difficult to interpret.
Explanation
High information density is useful only when the views remain coherent and understandable.
- 60
What is the general design rule for overlaying plots?
Model answer
Use views that complement and support one another rather than compete for attention.
Explanation
Restraint helps preserve a coherent interpretation of the combined graphic.
- 61
What does the
lynxdataset represent?Model answer
It contains annual Canadian lynx-trapping counts from 1821 through 1934.
Explanation
The dataset is a time series consisting of one sequence of numerical observations.
- 62
What does a normal-density curve overlaid on a histogram show?
Model answer
It shows how the observed distribution compares with a normal distribution having the same mean and standard deviation.
Explanation
The comparison helps reveal departures from normality, such as the strong low-end spike in the lynx data.
- 63
What is a kernel density estimator?
Model answer
It is a smooth, nonparametric estimate of the data distribution that can follow the observed shape more flexibly than a normal curve.
Explanation
Unlike a normal distribution, a kernel estimate does not assume a specific parametric shape.
- 64
What effect does increasing the adjustment parameter of a kernel density estimator have?
Model answer
It produces a smoother curve that changes more slowly and follows small features of the data less closely.
Explanation
In the example, a larger adjustment value created a smoother estimate than the default curve.
- 65
What information does a rug plot add to a histogram?
Model answer
It marks the location of each individual observation along the horizontal axis.
Explanation
The marks help explain why histogram bars have their observed heights and how the density estimate follows the data.
- 66
What numerical information does
summaryprovide for a categorical variable?Model answer
It provides the frequency or count of each category.
Explanation
For the iris species variable, it reports 50 observations for each of the three species.
- 67
What numerical information does
summaryprovide for a quantitative variable?Model answer
It provides the minimum, first quartile, median, mean, third quartile, and maximum.
Explanation
These statistics give a concise description of the variable's center and spread.
- 68
How can comparing the mean and median provide information about a distribution?
Model answer
Differences between the mean and median may indicate asymmetry or skewness.
Explanation
The two measures respond differently to unequal tails and unusually large or small observations.
- 69
What happens when
summaryis applied to an entire data frame?Model answer
It provides quantitative summaries for numerical variables and category counts for categorical variables.
Explanation
The function applies an appropriate summary based on each variable's type.
- 70
What is the purpose of the
describefunction?Model answer
It provides more detailed descriptive statistics than the basic
summaryfunction.Explanation
It is useful when the analyst needs additional information about the distribution of quantitative variables.
- 71
Which package provides the
describefunction?Model answer
The
describefunction comes from the contributedpsychpackage.Explanation
It is not part of R's basic built-in functionality.
- 72
What statistics can
describereport for quantitative variables?Model answer
It can report sample size, mean, standard deviation, median, trimmed mean, median absolute deviation, minimum, maximum, range, skewness, kurtosis, and standard error.
Explanation
These measures provide a more detailed view of center, spread, shape, and estimation precision.
- 73
Why should
describegenerally not be applied to categorical variables?Model answer
It is designed for quantitative variables, so numerical summaries of categories are not substantively meaningful.
Explanation
Categorical variables should instead be summarized with counts or frequencies.
- 74
What is the purpose of selecting cases in R?
Model answer
It focuses an analysis on particular observations or subgroups.
Explanation
Case selection allows the analyst to examine a narrower and more relevant portion of the data.
- 75
How can cases be selected by a categorical variable?
Model answer
Rows can be selected by specifying that a categorical variable equals a particular category, such as a species name in quotation marks.
Explanation
The category must be spelled and capitalized exactly as it appears in the data.
- 76
How can cases be selected by a quantitative variable?
Model answer
Rows can be selected by applying a numerical condition, such as choosing observations whose value is less than a specified amount.
Explanation
Quantitative selection uses logical comparisons to retain observations meeting the criterion.
- 77
How can multiple case-selection conditions be combined?
Model answer
Conditions can be combined with an ampersand so that only observations satisfying all conditions are retained.
Explanation
For example, an analyst can select one species and also require petal length to be below a specified value.
- 78
Why create a new data frame from selected cases?
Model answer
Saving a subset as a new data frame is useful when the same subgroup will be analyzed repeatedly.
Explanation
It avoids rewriting the selection condition for every subsequent analysis.
- 79
What does leaving the column position blank in a row-and-column selection do?
Model answer
It retains all columns while selecting only the specified rows.
Explanation
This is useful for creating a data frame containing every variable for a selected subgroup.
- 80
What are R data types?
Model answer
R data types include numeric, character, logical, complex, and raw data.
Explanation
Data types describe the kind of value stored in a variable.
- 81
How does R represent text values?
Model answer
R represents text as character data; it does not use a separate string type.
Explanation
Single characters and longer text strings are both treated as character values.
- 82
What are the defining characteristics of a vector?
Model answer
A vector is a one-dimensional collection whose elements are all the same data type; a single value is still a vector of length one.
Explanation
Vectors are R's basic data objects and underlie many other structures.
- 83
What are the defining characteristics of a matrix?
Model answer
A matrix is a two-dimensional structure with rows and columns in which all elements have the same data type.
Explanation
Matrix columns have equal lengths, and matrix positions are identified by numeric indexes rather than named columns.
- 84
How does an array differ from a matrix?
Model answer
An array is like a matrix but can have three or more dimensions.
Explanation
An array extends the row-and-column concept to additional dimensions or tables.
- 85
What is a data frame?
Model answer
A data frame is a two-dimensional structure whose columns can contain different data types but must all have the same length.
Explanation
It is the R structure most analogous to a spreadsheet and is commonly used for imported data.
- 86
Why is a data frame often more practical than a list for ordinary data analysis?
Model answer
A data frame supports multiple variable types while retaining a regular tabular structure that is easier to analyze than a highly flexible list.
Explanation
Lists can contain elements of any type, length, or structure, but that flexibility can make them difficult to work with.
- 87
What is an R list?
Model answer
A list is an ordered collection whose elements can have different types, lengths, and structures, including other lists.
Explanation
Lists are R's most flexible data structure but are often more complex to interpret.
- 88
What is coercion in R?
Model answer
Coercion is the conversion of an object from one data type or structure to another.
Explanation
Examples include converting characters to numeric values or matrices to data frames.
- 89
What happens during automatic coercion when numeric, character, and logical values are combined?
Model answer
They are generally converted to character values because character is the most general and least restrictive common type.
Explanation
Automatic coercion can be useful but may also unintentionally change the intended data types.
- 90
How can a numeric value be explicitly converted to an integer?
Model answer
It can be converted with
as.integer.Explanation
The displayed value may look unchanged, but its representation in memory becomes integer rather than double precision.
- 91
How can character representations of numbers be converted to numeric values?
Model answer
They can be converted with
as.numeric.Explanation
The quotation marks are removed and the values become numeric, normally using double precision.
- 92
How can a matrix be converted into a data frame?
Model answer
It can be converted with
as.data.frame.Explanation
The numerical values may look the same, but the resulting object supports data-frame functions and named variables.
- 93
What is a factor in R?
Model answer
A factor is an attribute of a vector that defines its possible categorical values and their order.
Explanation
Factors are useful for representing categorical variables in analyses.
- 94
How does a factor differ from an ordinary integer vector?
Model answer
A factor may be stored with integer codes but also has defined levels that identify the categories.
Explanation
The underlying numerical codes and the displayed category labels are separate aspects of the factor.
- 95
How can an existing vector be converted into a factor?
Model answer
It can be converted with
as.factor.Explanation
The resulting variable retains its underlying codes but is treated as a categorical variable with levels.
- 96
How can factor levels be assigned text labels?
Model answer
Text labels can be supplied when defining or reclassifying the factor, with the labels placed in the intended level order.
Explanation
For example, numerical codes can be labeled Mac OS, Windows, and Linux.
- 97
Why is the order of factor levels important?
Model answer
The level order determines how categories are organized and can communicate an intended sequence or ranking.
Explanation
Changing the level order can affect how categories appear in output and analyses.
- 98
What does the assignment operator do in R?
Model answer
The left-pointing assignment operator assigns a value to a variable.
Explanation
For example, an expression meaning that x gets 5 stores the value 5 in x.
- 99
What does the colon operator do?
Model answer
It generates a sequence of consecutive values between two endpoints, in ascending or descending order.
Explanation
Reversing the endpoints produces a descending sequence.
- 100
What is the purpose of the sequence function?
Model answer
It generates sequences while allowing the user to specify details such as the starting value, ending value, and step size.
Explanation
It is more flexible than the colon operator, such as when generating values that decrease by three.
- 101
What does the
cfunction do?Model answer
It concatenates, combines, or collects values into a vector.
Explanation
It is useful for entering an arbitrary collection of values in a chosen order.
- 102
How does the
scanfunction support data entry?Model answer
It allows values to be entered interactively in the console until the user submits a blank line.
Explanation
This can be convenient for entering a small number of values directly during an R session.
- 103
What does the
repfunction do?Model answer
It replicates values or groups of values a specified number of times.
Explanation
It can repeat one value, repeat a sequence as a unit, or repeat each value consecutively.
- 104
What are common file formats that can be imported into R?
Model answer
Common formats include CSV, plain text, Excel files, and JSON.
Explanation
CSV files are comma-separated text, Excel files use spreadsheet formats, and JSON is often used for web data.
- 105
Why are CSV files widely used for data exchange?
Model answer
They are plain-text spreadsheet files that nearly all spreadsheet and data-analysis programs can read and write.
Explanation
Their simplicity makes them broadly compatible across software systems.
- 106
What is JSON?
Model answer
JSON stands for JavaScript Object Notation and is a data format commonly encountered in web data.
Explanation
It provides a structured text representation for exchanging data.
- 107
What is the advantage of the
riopackage for importing data?Model answer
It provides one consistent import function that can automatically recognize and read many file formats.
Explanation
This avoids memorizing separate import functions and syntax for every file type.
- 108
Why does the R documentation generally recommend exporting Excel data before importing it?
Model answer
It recommends exporting Excel data as tab-delimited or comma-separated text when possible because those formats are simpler and more reliable to import.
Explanation
The documentation particularly warns that newer Excel formats may require additional handling.
- 109
What does R's data viewer provide?
Model answer
It displays a data frame in a spreadsheet-like, sortable interface.
Explanation
Users can inspect the data and sort columns to examine low-to-high or high-to-low values.
- 110
When is
read.tableappropriate, and what argument may be needed for tab-delimited data?Model answer
read.tablecan import text tables, and the separator argument should be set to a tab when the file is tab-delimited.Explanation
Specifying the separator is important when the default interpretation does not match the file structure.
- 111
Why does
read.csvnot require the user to specify a delimiter?Model answer
The CSV format is defined as comma-separated, so the function already knows which delimiter to use.
Explanation
The function can therefore read comma-separated files with less syntax.
- 112
What is hierarchical clustering used for?
Model answer
It identifies which observations are similar to one another and groups them according to their measured distances.
Explanation
The method implements the idea of finding which cases belong with other like cases.
- 113
What decisions influence the results of a clustering analysis?
Model answer
Results depend on the variables used, the distance or similarity measure, the clustering strategy, and the desired number of groups when applicable.
Explanation
Changing the data or methodological choices can produce different clusters.
- 114
How do divisive and agglomerative clustering differ?
Model answer
Divisive clustering begins with all observations in one group and splits them, whereas agglomerative clustering begins with separate observations and combines them.
Explanation
The two approaches build the hierarchy in opposite directions.
- 115
What choices were used for the introductory clustering example?
Model answer
The example used Euclidean distance, hierarchical clustering, and a divisive approach without setting the number of groups in advance.
Explanation
These choices provide a simple illustration of hierarchical grouping.
- 116
What does a dendrogram display?
Model answer
A dendrogram displays the nested splitting or joining of observations into clusters.
Explanation
Its branches show which observations remain together and where groups separate.
- 117
Why are the results of a clustering analysis limited to the selected data?
Model answer
Clusters are based only on the observations and variables supplied to the analysis, so changing either can change the grouping.
Explanation
Clustering does not reveal an absolute or universal classification independent of the input data.
- 118
What is principal component analysis, or PCA?
Model answer
PCA is a dimensionality-reduction method that transforms many correlated variables into fewer components while retaining important variation.
Explanation
The goal is to reduce complexity and noise without losing the most useful information.
- 119
How does the geometric analogy of PCA illustrate dimensionality reduction?
Model answer
PCA is like representing three-dimensional people with two-dimensional shadows that preserve much of the important information.
Explanation
The analogy shows how fewer dimensions can still capture meaningful characteristics of a more complex dataset.
- 120
What conceptual steps are used to illustrate PCA with two variables?
Model answer
A line is fitted through the data, perpendicular distances to the line are measured, points are projected onto the line, and the line may be rotated to a horizontal orientation.
Explanation
The resulting one-dimensional representation is the first principal component in the analogy.
- 121
Why are centering and scaling often used before PCA?
Model answer
Centering gives variables a mean of zero, and scaling gives them comparable variance so that variables with large measurement ranges do not dominate the analysis.
Explanation
Standardizing variables places them on a common scale.
- 122
How many principal components can PCA produce relative to the number of original variables?
Model answer
It can produce the same number of components as original variables, although usually only the first few explain substantial variation.
Explanation
The purpose is to focus on a smaller number of informative dimensions.
- 123
What does the standard deviation of a principal component indicate?
Model answer
It reflects how much variation that component represents relative to the standardized original variables.
Explanation
A component with a larger standard deviation accounts for more of the data's variation.
- 124
What is a scree plot used for in PCA?
Model answer
It displays the importance or explained variation of successive components and helps determine how many components to retain.
Explanation
Analysts can look for a sharp decline or an elbow in the component contributions.
- 125
What does the rotation matrix in a PCA output represent?
Model answer
It shows the associations between the original variables and the principal components.
Explanation
These associations help interpret what each component represents.
- 126
What does a PCA biplot display?
Model answer
It displays observations on the first two principal components along with directions representing the contributions of the original variables.
Explanation
The plot helps interpret both case positions and variable relationships in reduced-dimensional space.
- 127
How does PCA differ from hierarchical clustering in what it groups?
Model answer
Hierarchical clustering groups observations or cases, whereas PCA reveals major dimensions and relationships among variables.
Explanation
The two methods address different kinds of structure in multivariate data.
- 128
What is the main purpose of regression?
Model answer
Regression uses multiple predictor variables to predict scores on one outcome variable.
Explanation
It combines information from many variables to explain or predict a single response.
- 129
What do the predictor and outcome variables represent in a regression model?
Model answer
Predictors are the variables used to make the prediction, while the outcome is the single variable being predicted.
Explanation
In the judge-rating example, several evaluations predicted whether a judge should be retained.
- 130
What is simultaneous-entry regression?
Model answer
It enters all predictor variables into one regression equation at the same time.
Explanation
This is the simplest regression approach described in the content.
- 131
What does the
lmfunction represent in R?Model answer
lmfits a linear model.Explanation
The model formula uses the outcome followed by a tilde and the predictors used to explain or predict it.
- 132
What does the tilde mean in an R model formula?
Model answer
It separates the outcome from the variables used to predict it and can be read as 'is predicted by' or 'is a function of.'
Explanation
The expression places the outcome on the left and the predictors on the right.
- 133
What information is provided by regression coefficients?
Model answer
They indicate the predicted change in the outcome associated with a one-unit change in a predictor, along with the intercept representing the baseline prediction.
Explanation
The coefficients define the fitted prediction equation.
- 134
What inferential information does a regression summary provide for individual coefficients?
Model answer
It provides each coefficient's standard error, t statistic, and probability value.
Explanation
These values help evaluate whether individual predictors contribute evidence beyond sampling variability.
- 135
What do asterisks beside regression probability values indicate?
Model answer
They indicate probability values below conventional significance cutoffs, including the commonly used cutoff of 0.05.
Explanation
The symbols provide a quick visual indication of statistical significance.
- 136
What does multiple R-squared measure?
Model answer
It indicates how well the predictors collectively account for or predict variation in the outcome.
Explanation
A very high multiple R-squared means the predictors collectively predicted judge retention very well in the example data.
- 137
What is the purpose of the ANOVA table in a regression analysis?
Model answer
It provides an analysis-of-variance summary for the fitted regression model, including model and residual information.
Explanation
The table offers another way to examine the overall model and its unexplained variation.
- 138
What do confidence intervals for regression coefficients provide?
Model answer
They provide a range of plausible values for each population coefficient, such as a 95% confidence interval.
Explanation
The interval expresses uncertainty around the estimated coefficient.
- 139
Why examine a histogram of regression residuals?
Model answer
It helps assess the distribution of prediction errors and identify skewness or unusual residuals.
Explanation
Residual diagnostics can reveal whether the model's predictions have systematic problems.
- 140
What is stepwise regression?
Model answer
It is a regression approach that selects or enters predictors sequentially according to a specified procedure.
Explanation
The content presents it as one of several alternative regression methods and notes that it has known criticisms.
- 141
What is stagewise regression?
Model answer
Stagewise regression is a method similar to stepwise regression that was described as having better generalizability.
Explanation
It is one of the alternative regression procedures available through R packages.
- 142
What does the lasso stand for, and what does it do?
Model answer
Lasso stands for least absolute shrinkage and selection operator; it performs regression while shrinking coefficients and selecting predictors.
Explanation
It is one of the specialized regression methods used to compare predictive performance.
- 143
Why might different regression methods produce different results?
Model answer
They use different procedures for selecting, shrinking, or combining predictors, so their predictive performance can vary across datasets.
Explanation
The content notes that several methods performed similarly in the example but may differ substantially in other situations.
- 144
How are R and Python related as data-science tools?
Model answer
Both can perform most of the same data-science tasks, although Python also functions as a general-purpose programming language.
Explanation
Comparing the two languages can help users choose tools suited to their work.
- 145
Why is learning data-visualization principles separate from learning R graphics commands?
Model answer
R provides powerful visualization tools, but designing an effective and meaningful graphic requires separate knowledge of visualization principles.
Explanation
Knowing how to produce a graph does not automatically ensure that the graph communicates well.
- 146
What is machine learning in the context described?
Model answer
It involves processing large amounts of data to generate predictions that can be applied to other data.
Explanation
Machine-learning methods extend beyond the introductory statistical procedures presented here.
- 147
What resources can help users continue learning R?
Model answer
Users can explore additional courses, visualization and machine-learning materials, the annual useR conference, and local R user groups.
Explanation
These resources provide further instruction, community support, and opportunities to learn current practices.

Ask anything
We've read this whole study set, so questions about it get the best answers.