Running examples in ‘lessR-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: Regression
> ### Title: Regression Analysis
> ### Aliases: Regression reg reg.brief
> ### Keywords: regression
> 
> ### ** Examples
> 
> # read internal data set
> mydata <- rd("Reading", format="lessR", quiet=TRUE)

> # do not need all this data, so take only 30% to reduce CPU time
> mydata <- Subset(random=.3)

-----------------
Before the subset
-----------------

Number of variables in mydata: 4
Number of cases (rows) in mydata: 100

First five rows of data for data frame: mydata 
--------------------------------------------------------------------
  Reading Verbal Absent Income
1      73     64      4     36
2      77     80      2    103
3      42     54      9      4
4      83     60      2     95
5      94     91      0     75


Rows of data randomly extracted
------------------------------------------
Proportion of randomly retained rows:  0.3 
Number of randomly retained rows:  30 


----------------
After the subset
----------------

Number of variables : 4
Number of cases (rows) : 30


First five rows of data 
--------------------------------------------------------------------
   Reading Verbal Absent Income
1       73     64      4     36
6       84     67      0     90
10      45     60     12     35
16     100     79      0     91
17      80     65      5     89

> 
> # one-predictor regression
> # Provide all default analyses including scatterplot etc.
> # Can abbreviate Regression with reg
> Regression(Reading ~ Verbal)
dev.new(): using pdf(file="Rplots126.pdf")
dev.new(): using pdf(file="Rplots127.pdf")
dev.new(): using pdf(file="Rplots128.pdf")

>>> Suggestion
# Create an R markdown file for interpretative output with the Rmd option
# In RStudio, open and then knit this file to generate the output
Regression(my.formula=Reading ~ Verbal, Rmd="eg")  


  BACKGROUND

Data Frame:  mydata 
 
Response Variable: Reading, Reading Ability 
Predictor Variable: Verbal, Verbal Aptitude 
 
Number of cases (rows) of data:  30 
Number of cases retained for analysis:  30 


  BASIC ANALYSIS

Estimated Model 
 
             Estimate    Std Err  t-value  p-value   Lower 95%   Upper 95% 
(Intercept)    43.026     12.738    3.378    0.002      16.933      69.119 
     Verbal     0.459      0.184    2.502    0.018       0.083       0.835 


Model Fit 
 
Standard deviation of residuals:  10.462 for 28 degrees of freedom 
 
R-squared:  0.183    Adjusted R-squared:  0.153    PRESS R-squared:  0.092 

Null hypothesis that all population slope coefficients are 0:
  F-statistic: 6.259     df: 1 and 28     p-value:  0.018 


Analysis of Variance 
 
            df    Sum Sq   Mean Sq   F-value   p-value 
Model        1   684.982   684.982     6.259     0.018 
Residuals   28  3064.485   109.446 
Reading     29  3749.467   129.292 


  RELATIONS AMONG THE VARIABLES

Correlation Matrix
 
          Reading Verbal 
  Reading    1.00   0.43 
   Verbal    0.43   1.00 


  RESIDUALS AND INFLUENCE

Data, Fitted, Residual, Studentized Residual, Dffits, Cook's Distance 
   [sorted by Cook's Distance] 
   [res.rows = 20, out of 30 rows of data, or do res.rows="all"] 
------------------------------------------------------ 
     Verbal Reading fitted   resid rstdnt dffits cooks 
  10     60      45 70.583 -25.583 -2.810 -0.685 0.188 
  16     79     100 79.310  20.690  2.180  0.582 0.150 
  20     70      95 75.176  19.824  2.033  0.381 0.065 
  25     79      66 79.310 -13.310 -1.335 -0.357 0.062 
  63     63      57 71.961 -14.961 -1.494 -0.317 0.048 
  83     73      61 76.554 -15.554 -1.555 -0.314 0.047 
  67     69      90 74.717  15.283  1.520  0.283 0.038 
  21     49      71 65.531   5.469  0.561  0.237 0.029 
  19     73      88 76.554  11.446  1.121  0.227 0.025 
  88     66      63 73.339 -10.339 -1.007 -0.193 0.019 
   6     67      84 73.798  10.202  0.992  0.186 0.017 
  58     83      76 81.147  -5.147 -0.511 -0.168 0.014 
  75     68      65 74.258  -9.258 -0.897 -0.167 0.014 
  28     57      75 69.206   5.794  0.569  0.162 0.013 
  97     84      86 81.606   4.394  0.438  0.151 0.012 
  34     46      67 64.153   2.847  0.297  0.144 0.011 
  81     54      72 67.828   4.172  0.414  0.137 0.010 
  17     65      80 72.880   7.120  0.687  0.135 0.009 
  27     87      80 82.984  -2.984 -0.302 -0.121 0.008 
  32     75      72 77.473  -5.473 -0.529 -0.116 0.007 


  FORECASTING ERROR

Data, Predicted, Standard Error of Forecast, 95% Prediction Intervals 
   [sorted by lower bound of prediction interval] 
   [to see all intervals do pred.rows="all"] 
------------------------------------------------------- 
     Verbal Reading   pred     sf pi:lwr  pi:upr  width 
  34     46      67 64.153 11.415 40.770  87.537 46.766 
  21     49      71 65.531 11.227 42.534  88.528 45.994 
... 
  75     68      65 74.258 10.635 52.473  96.043 43.570 
  67     69      90 74.717 10.635 52.933  96.501 43.569 
  20     70      95 75.176 10.638 53.386  96.967 43.581 
... 
  97     84      86 81.606 11.004 59.066 104.147 45.081 
  62     86      83 82.525 11.104 59.779 105.270 45.491 
  27     87      80 82.984 11.158 60.128 105.841 45.713 


------------------------------------------------------------ 
Plot 1: Distribution of Residuals 
Plot 2: Residuals vs Fitted Values 
Plot 3: Regression Line, Confidence and Prediction Intervals 
------------------------------------------------------------ 

> # Provide only the brief analysis on the standardized variables
> reg.brief(Reading ~ Verbal, standardize=TRUE)
dev.new(): using pdf(file="Rplots129.pdf")

>>> Suggestion
# Create an R markdown file for interpretative output with the Rmd option
# In RStudio, open and then knit this file to generate the output
reg(Reading ~ Verbal, standardize=TRUE, Rmd="eg")  


  BACKGROUND

Data Frame:  mydata 
 
Response Variable: Reading, Reading Ability 
Predictor Variable: Verbal, Verbal Aptitude 
 
Number of cases (rows) of data:  30 
Number of cases retained for analysis:  30 
 
Data are Standardized 


  BASIC ANALYSIS

Estimated Model 
 
             Estimate    Std Err  t-value  p-value   Lower 95%   Upper 95% 
(Intercept)    -0.000      0.168   -0.000    1.000      -0.344       0.344 
     Verbal     0.428      0.171    2.503    0.018       0.078       0.777 


Model Fit 
 
Standard deviation of residuals:  0.920 for 28 degrees of freedom 
 
R-squared:  0.183    Adjusted R-squared:  0.154    PRESS R-squared:  0.092 

Null hypothesis that all population slope coefficients are 0:
  F-statistic: 6.264     df: 1 and 28     p-value:  0.018 


Analysis of Variance 
 
            df    Sum Sq   Mean Sq   F-value   p-value 
Model        1     5.302     5.302     6.264     0.018 
Residuals   28    23.698     0.846 
Reading     29    29.000     1.000 


  RELATIONS AMONG THE VARIABLES

  RESIDUALS AND INFLUENCE

  FORECASTING ERROR
> 
> # Access the pieces of output, here in an object named \code{r}
> r <- reg(Reading ~ Verbal + Absent + Income)
dev.new(): using pdf(file="Rplots130.pdf")
dev.new(): using pdf(file="Rplots131.pdf")
dev.new(): using pdf(file="Rplots132.pdf")
> # Display all output at the console in the standard sequence
> r

>>> Suggestion
# Create an R markdown file for interpretative output with the Rmd option
# In RStudio, open and then knit this file to generate the output
reg(Reading ~ Verbal + Absent + Income, Rmd="eg")  


  BACKGROUND

Data Frame:  mydata 
 
Response Variable: Reading, Reading Ability 
Predictor Variable 1: Verbal, Verbal Aptitude 
Predictor Variable 2: Absent, Number of Absences 
Predictor Variable 3: Income, Family Income ($1000) 
 
Number of cases (rows) of data:  30 
Number of cases retained for analysis:  30 


  BASIC ANALYSIS

Estimated Model 
 
             Estimate    Std Err  t-value  p-value   Lower 95%   Upper 95% 
(Intercept)    78.332     18.809    4.165    0.000      39.670     116.994 
     Verbal     0.120      0.215    0.560    0.580      -0.321       0.562 
     Absent    -2.327      0.905   -2.571    0.016      -4.188      -0.466 
     Income    -0.077      0.070   -1.090    0.286      -0.222       0.068 


Model Fit 
 
Standard deviation of residuals:  9.686 for 26 degrees of freedom 
 
R-squared:  0.349    Adjusted R-squared:  0.274    PRESS R-squared:  0.134 

Null hypothesis that all population slope coefficients are 0:
  F-statistic: 4.655     df: 3 and 26     p-value:  0.010 


Analysis of Variance 
 
            df    Sum Sq   Mean Sq   F-value   p-value 
   Verbal    1   684.982   684.982     7.301     0.012 
   Absent    1   513.754   513.754     5.476     0.027 
   Income    1   111.397   111.397     1.187     0.286 
Model        3  1310.134   436.711     4.655     0.010 
 
Residuals   26  2439.333    93.821 
 
Reading     29  3749.467   129.292 


  RELATIONS AMONG THE VARIABLES

Correlation Matrix
 
          Reading Verbal Absent Income 
  Reading    1.00   0.43  -0.55   0.06 
   Verbal    0.43   1.00  -0.57   0.04 
   Absent   -0.55  -0.57   1.00  -0.44 
   Income    0.06   0.04  -0.44   1.00 


Collinearity 
 
         Tolerance       VIF 
  Verbal     0.626     1.598 
  Absent     0.507     1.973 
  Income     0.746     1.340 


Best Subset Regression Models 
 
 Verbal Absent Income    R2adj    X's 
      0      1      1    0.293      2 
      0      1      0    0.275      1 
      1      1      1    0.274      3 
      1      1      0    0.269      2 
      1      0      0    0.153      1 
      1      0      1    0.124      2 
      0      0      1   -0.033      1 
 
[based on Thomas Lumley's leaps function from the leaps package] 
 


  RESIDUALS AND INFLUENCE

Data, Fitted, Residual, Studentized Residual, Dffits, Cook's Distance 
   [sorted by Cook's Distance] 
   [res.rows = 20, out of 30 rows of data, or do res.rows="all"] 
--------------------------------------------------------------------- 
     Verbal Absent  Income Reading fitted   resid rstdnt dffits cooks 
  10     60     12      35      45 54.935  -9.935 -1.455 -1.402 0.471 
  63     63      2     127      57 71.508 -14.508 -1.691 -0.735 0.126 
  16     79      0      91     100 80.851  19.149  2.208  0.647 0.091 
  20     70      0     111      95 78.233  16.767  1.913  0.629 0.090 
  21     49      8      15      71 64.457   6.543  0.790  0.491 0.061 
  83     73      1      74      61 79.107 -18.107 -2.030 -0.465 0.048 
  17     65      5      89      80 67.684  12.316  1.357  0.437 0.046 
  25     79      1      69      66 80.213 -14.213 -1.563 -0.428 0.043 
  34     46      6     110      67 61.459   5.541  0.661  0.399 0.041 
  28     57      6      84      75 64.778  10.222  1.127  0.404 0.040 
  81     54      0     100      72 77.153  -5.153 -0.610 -0.360 0.033 
  19     73      1      22      88 83.098   4.902  0.571  0.316 0.026 
  67     69      3      63      90 74.815  15.185  1.651  0.330 0.026 
  97     84      2      52      86 79.792   6.208  0.681  0.266 0.018 
  62     86      3      43      83 78.396   4.604  0.521  0.254 0.017 
  32     75      0     117      72 78.374  -6.374 -0.693 -0.251 0.016 
  51     65      2      48      72 77.813  -5.813 -0.628 -0.219 0.012 
  88     66      4      69      63 71.667  -8.667 -0.910 -0.187 0.009 
  75     68      3      81      65 73.313  -8.313 -0.871 -0.171 0.007 
   6     67      0      90      84 79.484   4.516  0.482  0.154 0.006 


  FORECASTING ERROR

Data, Predicted, Standard Error of Forecast, 95% Prediction Intervals 
   [sorted by lower bound of prediction interval] 
   [to see all intervals do pred.rows="all"] 
---------------------------------------------------------------------- 
     Verbal Absent  Income Reading   pred     sf pi:lwr  pi:upr  width 
  10     60     12      35      45 54.935 11.790 30.701  79.170 48.469 
  34     46      6     110      67 61.459 10.902 39.050  83.867 44.817 
... 
  57     61      3      71      70 73.239  9.969 52.747  93.731 40.984 
  75     68      3      81      65 73.313  9.864 53.037  93.590 40.552 
   1     64      4      36      73 73.959 10.171 53.053  94.865 41.813 
... 
  16     79      0      91     100 80.851 10.062 60.169 101.533 41.364 
  19     73      1      22      88 83.098 10.763 60.974 105.223 44.248 
  89     83      0      60      82 83.712 10.250 62.643 104.781 42.137 


---------------------------------- 
Plot 1: Distribution of Residuals 
Plot 2: Residuals vs Fitted Values 
Plot 3: ScatterPlot Matrix 
---------------------------------- 

> # list the names of all the saved components
> names(r)
 [1] "out_suggest"     "call"            "formula"         "out_title_bck"   "out_background"  "out_title_basic"
 [7] "out_estimates"   "out_fit"         "out_anova"       "out_title_rel"   "out_cor"         "out_collinear"  
[13] "out_subsets"     "out_title_res"   "out_residuals"   "out_title_pred"  "out_predict"     "out_ref"        
[19] "out_Rmd"         "out_plots"       "n.vars"          "n.obs"           "n.keep"          "coefficients"   
[25] "sterrs"          "tvalues"         "pvalues"         "cilb"            "ciub"            "anova_model"    
[31] "anova_residual"  "anova_total"     "se"              "resid_range"     "Rsq"             "Rsqadj"         
[37] "PRESS"           "RsqPRESS"        "cor"             "tolerances"      "vif"             "resid.max"      
[43] "pred_min_max"    "residuals"       "fitted"          "cooks.distance"  "model"           "terms"          
> # Display just the estimated coefficients and their inferential analysis
> r$out_estimates
Estimated Model 
 
             Estimate    Std Err  t-value  p-value   Lower 95%   Upper 95% 
(Intercept)    78.332     18.809    4.165    0.000      39.670     116.994 
     Verbal     0.120      0.215    0.560    0.580      -0.321       0.562 
     Absent    -2.327      0.905   -2.571    0.016      -4.188      -0.466 
     Income    -0.077      0.070   -1.090    0.286      -0.222       0.068 
> 
> # Generate an R markdown file with the option: Rmd
> # Output file here will be read.Rmd, a simple text file that can
> #   be edited with any text editor including RStudio from which it
> #   can be knit to generate dynamic output to a Word document,
> #   pdf file or html file
> reg(Reading ~ Verbal + Absent, Rmd="read")
dev.new(): using pdf(file="Rplots133.pdf")
dev.new(): using pdf(file="Rplots134.pdf")
dev.new(): using pdf(file="Rplots135.pdf")
Error in var.unit[i] <- myunits[which(names(myunits) == nm[i])] : 
  replacement has length zero
Calls: reg -> Regression -> .reg.Rmd
Execution halted