R language Access Menu

Title Text Both  

Linear regression using package rms

Package rms is very useful package with many utilities for advanced regression. It has ols function for linear regression, lrm for logistic and ordinal regression.

Code:

> library(rms)
> mod = ols(bwt~age+lwt+race+smoke+ptl+ht+ui+ftv, data=bwdf)
# full formula needs to be entered in command;
> bwdf = mybwdf(F) 
# FALSE to get 'bwt' numeric variable rather than 'low' categorical
> mod

Linear Regression Model

ols(formula = bwt ~ age + lwt + race + smoke + ptl + ht + ui + 
    ftv, data = bwdf)

                  Model Likelihood     Discrimination    
                     Ratio Test           Indexes        
Obs        189    LR chi2     52.55    R2       0.243    
sigma 650.3214    d.f.            9    R2 adj   0.205    
d.f.       179    Pr(> chi2) 0.0000    g      405.222    

Residuals

     Min       1Q   Median       3Q      Max 
-1825.26  -435.21    55.91   473.46  1701.20 

          Coef      S.E.     t     Pr(>|t|)
Intercept 2927.9619 312.9043  9.36 <0.0001 
age         -3.5699   9.6202 -0.37 0.7110  
lwt          4.3540   1.7356  2.51 0.0130  
race=2    -488.4275 149.9845 -3.26 0.0013  
race=3    -355.0771 114.7533 -3.09 0.0023  
smoke=1   -352.0445 106.4764 -3.31 0.0011  
ptl        -48.4020 101.9716 -0.47 0.6356  
ht=1      -592.8274 202.3212 -2.93 0.0038  
ui=1      -516.0810 138.8854 -3.72 0.0003  
ftv        -14.0581  46.4680 -0.30 0.7626  

References:

Frank E Harrell Jr (2015). rms: Regression Modeling Strategies. R package version 4.3-1.
http://CRAN.R-project.org/package=rms
 


    Comments & Feedback