Hi! I have a svyglm() weighted linear regression model and would like to obtain the standardized betas of the regression coefficients. I have tried to get them with the lm.beta() function, however when I do this the p-values of the coefficients change. I have also tried with the effectsize:standardize_parameters() function, but this returns the unstandardized coefficients (the same ones as in the original svyglm() model). How can I obtain the standardized coefficients of the svyglm() model with the correct p-values? Any help would be greatly appreciated. Here is the code for the model:
library(tidyverse)
library(lm.beta)
library(survey)
library(sjstats)
dat <- read.csv("https://raw.githubusercontent.com/LucasTremlett/questions/master/questiondata.csv")
dat.weighted<- svydesign(ids = ~1, data = dat, weights = dat$weight)
model.weighted<- svyglm(DV~IV1+IV2+IV3, design=dat.weighted)
summary(model.weighted)
Here is the code for the two methods that have not worked for me
##Withlmbeta()
model.weighted.lm.beta <- lm.beta(model.weighted)
summary(model.weighted.lm.beta)
##Witheffectsize:standardize_parameters()
effectsize::standardize_parameters(model.weighted)
What do you mean when you say they don't work? It "works" for me in that there are no errors or problems with the code.
library(tidyverse)
library(lm.beta)
library(survey)
#> Loading required package: grid
#> Loading required package: Matrix
#>
#> Attaching package: 'Matrix'
#> The following objects are masked from 'package:tidyr':
#>
#> expand, pack, unpack
#> Loading required package: survival
#>
#> Attaching package: 'survey'
#> The following object is masked from 'package:graphics':
#>
#> dotchart
library(sjstats)
#>
#> Attaching package: 'sjstats'
#> The following object is masked from 'package:survey':
#>
#> cv
dat <- read.csv("https://raw.githubusercontent.com/LucasTremlett/questions/master/questiondata.csv")
dat.weighted<- svydesign(ids = ~1, data = dat, weights = dat$weight)
model.weighted<- svyglm(DV~IV1+IV2+IV3, design=dat.weighted)
summary(model.weighted)
#>
#> Call:
#> svyglm(formula = DV ~ IV1 + IV2 + IV3, design = dat.weighted)
#>
#> Survey design:
#> svydesign(ids = ~1, data = dat, weights = dat$weight)
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 7.32065 0.97863 7.481 1.79e-13 ***
#> IV1 0.57412 0.50718 1.132 0.257956
#> IV2 -0.01029 0.01510 -0.681 0.495991
#> IV3 -0.53752 0.15370 -3.497 0.000494 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> (Dispersion parameter for gaussian family taken to be 14.14836)
#>
#> Number of Fisher Scoring iterations: 2
##Withlmbeta()
model.weighted.lm.beta <- lm.beta(model.weighted)
summary(model.weighted.lm.beta)
#>
#> Call:
#> svyglm(formula = DV ~ IV1 + IV2 + IV3, design = dat.weighted)
#>
#> Weighted Residuals:
#> Min 1Q Median 3Q Max
#> -19.7331 -2.1371 -0.7513 1.9734 13.7321
#>
#> Coefficients:
#> Estimate Standardized Std. Error t value Pr(>|t|)
#> (Intercept) 7.320655 0.000000 0.689727 10.614 < 2e-16 ***
#> IV1 0.574116 0.066581 0.275336 2.085 0.0373 *
#> IV2 -0.010288 -0.040034 0.008166 -1.260 0.2081
#> IV3 -0.537517 -0.161916 0.121259 -4.433 1.05e-05 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Residual standard error: 3.768 on 879 degrees of freedom
#> (809 observations deleted due to missingness)
#> Multiple R-squared: 0.02851, Adjusted R-squared: 0.02519
#> F-statistic: 8.597 on 3 and 879 DF, p-value: 1.253e-05
##Witheffectsize:standardize_parameters()
effectsize::standardize_parameters(model.weighted)
#> Parameter | Coefficient (std.) | 1e+02% CI
#> -------------------------------------------------
#> (Intercept) | 7.32 | [ 5.40, 9.24]
#> IV1 | 0.57 | [-0.42, 1.57]
#> IV2 | -0.01 | [-0.04, 0.02]
#> IV3 | -0.54 | [-0.84, -0.24]
#>
#> # Standardization method: Refit
effectsize::standardize_parameters(model.weighted.lm.beta)
#> Parameter | Coefficient (std.) | 1e+02% CI
#> -------------------------------------------------
#> (Intercept) | 7.32 | [ 5.40, 9.24]
#> IV1 | 0.57 | [-0.42, 1.57]
#> IV2 | -0.01 | [-0.04, 0.02]
#> IV3 | -0.54 | [-0.84, -0.24]
#>
#> # Standardization method: Refit
Created on 2020-10-05 by the reprex package (v0.3.0)
"Don't work" was a confusing way to put it, sorry about that. Basically, the model that lm.beta() produces has different standard errors than the one svygml() produces. I don't know why this is the case.
system
Closed
October 26, 2020, 5:29pm
4
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.