2
$\begingroup$

I used bas.lm() function to build a bayesian model in R, but when it comes to run the get_regression_table(model) and get_regression_points(model), it says "Only simple and multiple linear regression models are supported. Try again using lm for your models as appropriate". I have a linear model in the form of $y=a+b_i X_i$, my variables are counted in rates (values from 0 to 1). What should i do? my code is:

model <- bas.lm(V128 ~ . , data = subset, method="MCMC", prior = "ZS-null", modelprior = uniform()) 

my data are: https://i.sstatic.net/wFTRV.png

$\endgroup$
4
  • 1
    $\begingroup$ Can you include the R code you used to build your model in your question? It's hard to answer your question without seeing the actual R code. $\endgroup$ Commented Nov 16, 2019 at 21:39
  • 1
    $\begingroup$ I put my coding as well $\endgroup$
    – Eva
    Commented Nov 17, 2019 at 17:18
  • 1
    $\begingroup$ Thanks, Eva! Can you also add some information on your "subset" data? For example, use the command head(subset, 2) and show the first two rows of your data. (You can manually alter some of the actual data values when you add the output to your post in order to preserve the confidentiality of your data - if the actual value is 2.5, say, just change it to something else that is "close enough".) Also, show the output of the command str(subset) (possibly with manually altered data values) to enable us to understand what predictor variables you have in your data and how R treats them. $\endgroup$ Commented Nov 17, 2019 at 18:11
  • 1
    $\begingroup$ Thank you for the instruction. I have uploaded my data information. $\endgroup$
    – Eva
    Commented Nov 18, 2019 at 1:45

1 Answer 1

2
$\begingroup$

It looks like you are using the get_regression_table() function from the moderndive package to extract the summary of the model object produced by the bas.lm() function. However, the get_regression_table() function expects your model object to be obtained with the lm() function not with the bas.lm() function. This is the reason you are seeing the error.

Commands that would work for your bas.lm() model object include:

summary(model): used to print a summary of the results;

plot(model): used to plot posterior distributions for the model coefficients;

coefficients(model): used to extract the posterior summaries of model coefficients.

See R's help documentation for more details: https://www.rdocumentation.org/packages/BAS/versions/0.3/topics/bas.lm.

The same explanation applies to the function get_regression_points() from the moderndive package - the function only accepts lm() model objects, but your model object is a bas.lm() model object, which is not recognized by get_regression_points(). You can see this from the help file for get_regression_points(), which states: "Currently only lm is supported.".

$\endgroup$
4
  • $\begingroup$ So i can get the information from the regressions table and regression points by the summary(model), plot(model) etc? $\endgroup$
    – Eva
    Commented Nov 18, 2019 at 13:09
  • $\begingroup$ The moderndive package was NOT written for use with bam.ls objects, so there is no reason to expect that you would get identical information from commands that were written for bam.ls objects, like summary(). You just need to play with the commands I suggested and see what you get. $\endgroup$ Commented Nov 18, 2019 at 16:24
  • 1
    $\begingroup$ okay, thank you very much!!!! $\endgroup$
    – Eva
    Commented Nov 18, 2019 at 17:20
  • $\begingroup$ You're welcome, Eva! 🤗 $\endgroup$ Commented Nov 18, 2019 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.