Reputation: 11
First off, I'll start by saying that I do not know how to use R, but I need to do reduced major axis regression for the two variables below, and the lmodel2 function can do this. I learnt the code below to obtain the intercept and slope for the regression equation. However I don't get a R squared or a p-value for the regression. How would I do this? The code I have used so far is below.
Tensor_force=c(1.72,1.48,1.37,0.81,0.75,0.96,0.96,0.78,0.54,0.67,0.75,0.66,0.4)
Stapedius_force=c(0.8,0.58,1.07,0.82,0.77,0.98,0.99,0.98,0.92,1.06,1.19,1.32,1.18)
library(lmodel2)
lmodel2(Stapedius_force ~ Tensor_force,,"relative", "relative",0)
Upvotes: 1
Views: 212
Reputation: 6628
library(lmodel2)
mod1 <- lmodel2(Stapedius_force ~ Tensor_force,,"relative", "relative",0)
#> No permutation test will be performed
The lmodel2
object created by the lmodel2()
function is basically a list,
that is printed in a fashion so that the user can better read the results.
You can access individual values by subsetting that list. If you write
mod1$
and look at the auto complete options you’ll see the available values names.
rsquare
and P.param
are the names you are looking for:
mod1$rsquare
#> [1] 0.2905577
mod1$P.param # 2 tailed
#> [1] 0.0573178
mod1$P.param/2 # 1 tailed
#> [1] 0.0286589
If you are working with several different iterations of the same model
the broom
package and its glance()
function are very useful, as it
extracts the model quality measurments as a data.frame
/tibble
so you can
easily conduct further analysis on these values. See https://broom.tidymodels.org/ to learn more.
library(broom)
glance(mod1)
#> # A tibble: 1 x 5
#> r.squared theta p.value H nobs
#> <dbl> <dbl> <dbl> <dbl> <int>
#> 1 0.291 28.2 0.0573 0.0986 13
Upvotes: 4