You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug report::report fails when model is built using reformulate.
To Reproduce
See the following reprex:
library(report)
model<- lm(Sepal.Length~Species, data=iris)
model$terms#> Sepal.Length ~ Species#> attr(,"variables")#> list(Sepal.Length, Species)#> attr(,"factors")#> Species#> Sepal.Length 0#> Species 1#> attr(,"term.labels")#> [1] "Species"#> attr(,"order")#> [1] 1#> attr(,"intercept")#> [1] 1#> attr(,"response")#> [1] 1#> attr(,".Environment")#> <environment: R_GlobalEnv>#> attr(,"predvars")#> list(Sepal.Length, Species)#> attr(,"dataClasses")#> Sepal.Length Species #> "numeric" "factor"
report(model)
#> We fitted a linear model (estimated using OLS) to predict Sepal.Length with#> Species (formula: Sepal.Length ~ Species). The model explains a statistically#> significant and substantial proportion of variance (R2 = 0.62, F(2, 147) =#> 119.26, p < .001, adj. R2 = 0.61). The model's intercept, corresponding to#> Species = setosa, is at 5.01 (95% CI [4.86, 5.15], t(147) = 68.76, p < .001).#> Within this model:#> #> - The effect of Species [versicolor] is statistically significant and positive#> (beta = 0.93, 95% CI [0.73, 1.13], t(147) = 9.03, p < .001; Std. beta = 1.12,#> 95% CI [0.88, 1.37])#> - The effect of Species [virginica] is statistically significant and positive#> (beta = 1.58, 95% CI [1.38, 1.79], t(147) = 15.37, p < .001; Std. beta = 1.91,#> 95% CI [1.66, 2.16])#> #> Standardized parameters were obtained by fitting the model on a standardized#> version of the dataset. 95% Confidence Intervals (CIs) and p-values were#> computed using a Wald t-distribution approximation.x<-'Species'y<-'Sepal.Length'model<- lm(reformulate(x, response=y), data=iris)
model$terms#> Sepal.Length ~ Species#> attr(,"variables")#> list(Sepal.Length, Species)#> attr(,"factors")#> Species#> Sepal.Length 0#> Species 1#> attr(,"term.labels")#> [1] "Species"#> attr(,"order")#> [1] 1#> attr(,"intercept")#> [1] 1#> attr(,"response")#> [1] 1#> attr(,".Environment")#> <environment: R_GlobalEnv>#> attr(,"predvars")#> list(Sepal.Length, Species)#> attr(,"dataClasses")#> Sepal.Length Species #> "numeric" "factor"
report(model)
#> Error in reformulate(x, response = y): 'termlabels' must be a character vector of length at least one#> Error: Unable to refit the model with standardized data.#> Try instead to standardize the data (standardize(data)) and refit the#> model manually.
Describe the bug
report::report
fails when model is built using reformulate.To Reproduce
See the following reprex:
Created on 2023-09-05 with reprex v2.0.2
Expected behaviour
I expected a consistent output from the report function regardless of if the model formula was built using reformulate or not.
Screenshots
If applicable, add screenshots to help explain your problem.
Specifications (please complete the following information):
The text was updated successfully, but these errors were encountered: