Hi

Anyone able to help me with this.
I'm doing a datacamp course and the effect of adding a "bogus variable" to a 
linear model.
I make a model and initially fmodel works fine.
When I have a second model which uses this "bogus variable" it complains about 
the type of this variable.

The code below works fine.

library(statisticalModeling)
library(mosaicData)
print(names(CPS85))

# Add bogus column to CPS85 (don't change)
CPS85$bogus <- rnorm(nrow(CPS85)) > 0
cat ("typeof(CPS88$bogus) is:", typeof(CPS85$bogus), "\n")
# Make the base model
base_model <- lm(wage ~ educ + sector + sex, data = CPS85)
print(fmodel(base_model))

# Make the bogus augmented model
aug_model <- lm(wage ~ educ + sector +sex  + bogus, data = CPS85)
#print(fmodel((aug_model)))

# Find the MSE of the base model
mean_base <- mean((CPS85$wage - predict(base_model, newdata = CPS85)) ^ 2)

# Find the MSE of the augmented model
mean_aug <- mean((CPS85$wage - predict(aug_model, newdata = CPS85)) ^ 2)
cat("Mean Square Error of base", mean_base,"\n")
cat("Mean Square Error of aug", mean_aug)

However if I uncomment #print(fmodel((aug_model)))
I get

Error: variable 'bogus' was fitted with type "logical" but type "character" was 
supplied

Any pointers gratefully accepted

Cheer Paul J


Paul Johnston
Field Support (Slough House)
University of Manchester
Room B29
Pariser  Building
Tel 07826 875504
IOSH Managing Safely
Cert No.: 506572



        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to