harrelfe / Hmisc

Harrell Miscellaneous
Other
210 stars 81 forks source link

ols fails in 4.4-1, while working in 4.3-1 #38

Closed romantseg closed 8 years ago

romantseg commented 8 years ago

It seems that in 4.4-1 ols fails for the same code that works in 4.3-1

v.4.4-1

> sessionInfo()
...
other attached packages:
[1] pander_0.6.0    rms_4.4-1       SparseM_1.6     Hmisc_3.17-0    ggplot2_1.0.1   Formula_1.2-1  
[7] survival_2.38-3 lattice_0.20-33

> set.seed(123)
> n <- 1000
> age <- rnorm(n, 50, 10)
> cholesterol <- rnorm(n, 200, 25)
> sex <- factor(sample(c("female", "male"), n, TRUE))
> health <- data.frame(age, cholesterol)
> dd <- datadist(age, sex) # Is needed for summary() below
> options(datadist = 'dd')    
> ols(cholesterol ~ age + sex)
subscript out of bounds
1: withCallingHandlers(eval(code, new_test_environment), error = capture_calls, message = function(c) invokeRestart("muffleMessage"))
2: eval(code, new_test_environment)
3: eval(expr, envir, enclos)
4: ols(cholesterol ~ age + sex)

v.4.3-1

> package_url <- 'https://cran.r-project.org/src/contrib/Archive/rms/rms_4.3-1.tar.gz'
> install.packages(package_url, repos=NULL, type="source")
...
> sessionInfo()
...
other attached packages:
[1] pander_0.6.0    rms_4.3-1       SparseM_1.6     Hmisc_3.17-0    ggplot2_1.0.1   Formula_1.2-1  
[7] survival_2.38-3 lattice_0.20-33

> set.seed(123)
> n <- 1000
> age <- rnorm(n, 50, 10)
> cholesterol <- rnorm(n, 200, 25)
> sex <- factor(sample(c("female", "male"), n, TRUE))
> health <- data.frame(age, cholesterol)
> dd <- datadist(age, sex) # Is needed for summary() below
> options(datadist = 'dd')    
> ols(cholesterol ~ age + sex)
Linear Regression Model

ols(formula = cholesterol ~ age + sex)

                 Model Likelihood     Discrimination    
                    Ratio Test           Indexes        
Obs      1000    LR chi2      7.73    R2       0.008    
sigma 25.1697    d.f.            2    R2 adj   0.006    
d.f.      997    Pr(> chi2) 0.0210    g        2.501    

Residuals

      Min        1Q    Median        3Q       Max 
-75.32269 -17.42416  -0.05717  17.86732  82.67025 

          Coef     S.E.   t     Pr(>|t|)
Intercept 190.4515 4.2067 45.27 <0.0001 
age         0.2188 0.0803  2.72 0.0066  
sex=male   -0.7503 1.5932 -0.47 0.6378  
harrelfe commented 8 years ago

This issue should have been reported under the rms project. The problem is that I did not update the version of Hmisc required by rms in the rms DESCRIPTION file. If you update Hmisc to the version that is on CRAN this problem goes away.

romantseg commented 8 years ago

Sorry for filing the issue at a wrong place and thanks for a quick answer