IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 103 forks source link

The new object stuff isn't working for the modelling dialogues #7982

Open rdstern opened 1 year ago

rdstern commented 1 year ago

@Patowhiz The problem below is the same (I think) so none of the Fit Model dialogues now work. I have tried 2 variables, 3 variables and general. @lloyddewit I should have checked this earlier, but I didn't know that - in addition to the html in the output window - the whole saving of objects seems to be changed. I didn't test any of this.

With the survey data I use the Model > Two variable > Fit dialogue as follows: image

It looks the same in Version 0.7.7 and the new merged version. It runs fine in 7.7 and gives an error in the merged version. Here is the R code in the 2 versions: Version 0.7.7:

# Code generated by the dialog, Two Variable Fit Model

survey <- data_book$get_data_frame(data_name="survey")
attach(what=survey)
two_var1 <- lm(data=survey, formula=yield ~ fert, na.action=na.exclude)
data_book$add_model(model_name="two_var1", model=two_var1, data_name="survey")
data_book$get_models(data_name="survey", model_name="two_var1")
stats::anova(object=data_book$get_models(data_name="survey", model_name="two_var1"))
summary(object=data_book$get_models(data_name="survey", model_name="two_var1"))
detach(name=survey, unload=TRUE)
rm(list=c("two_var1", "survey"))

It is a lot longer in the new version!

# Code generated by the dialog, Two Variable Fit Model

survey <- data_book$get_data_frame(data_name="survey")
attach(what=survey)
survey <- data_book$get_data_frame(data_name="survey")
two_var2 <- lm(data=survey, formula=yield ~ fert, na.action=na.exclude)
data_book$add_object(data_name="survey", object_name="two_var2", object_type_label="model", object_format="text", object=two_var2)
data_book$get_object(data_name="survey", object_name="two_var2")
survey <- data_book$get_data_frame(data_name="survey")
two_var2 <- lm(data=survey, formula=yield ~ fert, na.action=na.exclude)
data_book$add_object(data_name="survey", object_name="two_var2", object_type_label="model", object_format="text", object=two_var2)
stats::anova(object=data_book$get_object(data_name="survey", object_name="two_var2"))
survey <- data_book$get_data_frame(data_name="survey")
two_var2 <- lm(data=survey, formula=yield ~ fert, na.action=na.exclude)
data_book$add_object(data_name="survey", object_name="two_var2", object_type_label="model", object_format="text", object=two_var2)
summary(object=data_book$get_object(data_name="survey", object_name="two_var2"))
survey <- data_book$get_data_frame(data_name="survey")
detach(name=survey, unload=TRUE)
rm(list=c("two_var2", "survey"))

Two things are a bit disturbing here. a) The code in R-Instat for simple regression was already longer than ordinary code in R. So I wonder why it needs to be so much longer? b) It doesn't work! It gives this error:

image

I wonder what is going on. I know @Patowhiz needs to finalise the way objects are now generated and used. I didn't think it would make such a big difference to the R code?

Patowhiz commented 1 year ago

@rdstern can you confirm that this now works fine? If so then can this now be closed.