dstanley4 / apaTables

Development version of apaTables R package. Current stable version is on the CRAN.
http://dstanley4.github.io/apaTables/
Other
55 stars 13 forks source link

apa.reg.table_issue with displaying of beta #42

Open jsbyn opened 3 months ago

jsbyn commented 3 months ago

Hello

I am currently stuck with creating an apa-reg-table. Usually, there are columns for beta in the output. However, these columns do not appear in my output (i.e., I only have the columns b/b 95% CI/sr2/sr2 95% CI/Fit/Difference). All of my variables (i.e., predictor variables, interaction term and outcome variable) are numeric. I highly appreciate any help. Thank you!

dstanley4 commented 3 months ago

Can you use a glimpse() command on your data to confirm none of the variables are factors? On May 16, 2024 at 12:11 PM -0400, jsbyn @.***>, wrote:

CAUTION: This email originated from outside of the University of Guelph. Do not click links or open attachments unless you recognize the sender and know the content is safe. If in doubt, forward suspicious emails to @.***

Hello

I am currently stuck with creating an apa-reg-table. Usually, there are columns for beta in the output. However, these columns do not appear in my output (i.e., I only have the columns b/b 95% CI/sr2/sr2 95% CI/Fit/Difference). All of my variables (i.e., predictor variables, interaction term and outcome variable) are numeric. I highly appreciate any help. Thank you!

— Reply to this email directly, view it on GitHubhttps://github.com/dstanley4/apaTables/issues/42, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AADGFZRBGVFVKL6JRTZLYHTZCTLDXAVCNFSM6AAAAABH2RCCJKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGMYDAOBRGA4DCOI. You are receiving this because you are subscribed to this thread.Message ID: @.***>

jsbyn commented 3 months ago
glimpse(mydata)
Rows: 110
Columns: 40
$ tn_code             <chr> "C10J115", "M03A047", "E11P088", "R03G064", "C03M047", "J04B036", "G10M018", "M04T091", "V09M048", "A01W105", "S12F…
$ mean_de_xfinal    <dbl> 3.500, 4.125, 4.500, 4.000, 4.500, 4.000, 4.000, 4.500, 4.500, 4.375, 4.375, 4.375, 4.250, 4.125, 3.875, 3.500, 4.0…
$ mean_de_yfinal    <dbl> 3.125, 3.625, 3.750, 3.500, 4.250, 3.625, 4.000, 4.125, 4.500, 4.125, 3.875, 1.625, 3.250, 3.500, 4.000, 4.000, 3.6…
$ mean_fk_x       <dbl> 5.25, 6.00, 6.00, 5.75, 5.75, 5.75, 4.75, 4.50, 4.25, 6.00, 5.25, 7.00, 6.00, 4.00, 7.00, 5.25, 6.00, 5.75, 6.25, 7…
$ mean_fk_y       <dbl> 5.25, 6.00, 6.00, 5.75, 5.75, 6.00, 4.25, 4.75, 5.00, 6.00, 4.75, 7.00, 6.00, 5.00, 4.25, 4.50, 6.00, 5.25, 6.25, 7…
$ mean_tn_himx   <dbl> 2.666667, 2.666667, 4.000000, 3.666667, 5.000000, 4.000000, 4.000000, 3.333333, 4.666667, 4.333333, 4.666667, 3.000…
$ mean_tn_y   <dbl> 3.666667, 3.000000, 3.666667, 3.000000, 3.666667, 4.000000, 3.666667, 3.333333, 3.666667, 4.000000, 2.666667, 2.000…

And this is the code I am using to (a) calculate the regression analyses and (b) create the apa-reg-table

#(1) model without interaction
reg_yint_yfk_himy <- lm(mean_fk_y ~mean_de_yfinal + mean_tn_y, data = mydata)

#(2) model with interaction
mod_yint_yfk_himy <- lm(mean_fk_y ~mean_de_yfinal * mean_tn_y, data = mydata)

apa.reg.table(reg_yint_yfk_himy , mod_yint_yfk_himy ,filename="RegModTable.doc")

What is even more confusing: When I do not include the interaction term in the model, then I get the "beta" columns in my output.

Thank you !

florgiulianimdq commented 1 week ago

Hi! I have the same problem, were you able to fix it?

dstanley4 commented 1 week ago

As per the documentation you need to use I() around the product term: blk1 <- lm(sales ~ adverts + airplay + I(adverts * airplay), data=album)

florgiulianimdq commented 1 week ago

Thanks! I do not have and interaction term.

lm_1 <- lm(delta_ryff ~ Edad + Genero + Nivel + Rol , base) lm_2 <- lm(delta_ryff ~ Edad + Genero + Nivel + Rol + responsabilidad + extraversion + agradabilidad + neuroticismo + apertura, base)

lm_3 <-lm( delta_ryff ~ Edad + Genero + Nivel + Rol + responsabilidad + extraversion + agradabilidad + neuroticismo + apertura + delta_Cansancio + delta_STAI + delta_Estres, base)

lm_4 <- lm(delta_ryff ~ Edad + Genero + Nivel + Rol + responsabilidad + extraversion + agradabilidad + neuroticismo + apertura + delta_AEF + delta_mait + delta_Cansancio + delta_STAI + delta_Estres + delta_ffmq + delta_scs + delta_Prosoc + delta_AEF + delta_mait + delta_Mindset, base)

apa.reg.table(lm_1,lm_2, lm_3, lm_4, filename="exInteraction1.doc")

dstanley4 commented 1 week ago

Perhaps the underscore in your variable names is causing a problem. This was previously an issue - but I thought it was fixed. Try renaming your variable to see if removing the underscore in your variable names fixes the problem. If so - please let me know. Cheers, David

David Stanley, PhD | Associate Professor Department of Psychology | University of Guelph 50 Stone Rd E | Guelph, ON | N1G 2W1 @. On Aug 27, 2024 at 9:40 AM -0400, florgiulianimdq @.>, wrote:

CAUTION: This email originated from outside of the University of Guelph. Do not click links or open attachments unless you recognize the sender and know the content is safe. If in doubt, forward suspicious emails to @.***

Thanks! I do not have and interaction term.

lm_1 <- lm(delta_ryff ~ Edad + Genero + Nivel + Rol , base) lm_2 <- lm(delta_ryff ~ Edad + Genero + Nivel + Rol + responsabilidad + extraversion + agradabilidad + neuroticismo + apertura, base)

lm_3 <-lm( delta_ryff ~ Edad + Genero + Nivel + Rol + responsabilidad + extraversion + agradabilidad + neuroticismo + apertura + delta_Cansancio + delta_STAI + delta_Estres, base)

lm_4 <- lm(delta_ryff ~ Edad + Genero + Nivel + Rol + responsabilidad + extraversion + agradabilidad + neuroticismo + apertura + delta_AEF + delta_mait + delta_Cansancio + delta_STAI + delta_Estres + delta_ffmq + delta_scs + delta_Prosoc + delta_AEF + delta_mait + delta_Mindset, base)

apa.reg.table(lm_1,lm_2, lm_3, lm_4, filename="exInteraction1.doc")

— Reply to this email directly, view it on GitHubhttps://github.com/dstanley4/apaTables/issues/42#issuecomment-2312594994, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AADGFZU6OQSCDEIRR5SN7ELZTR6S3AVCNFSM6AAAAABH2RCCJKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMJSGU4TIOJZGQ. You are receiving this because you commented.Message ID: @.***>

florgiulianimdq commented 1 week ago

Thank you so much! I´ll try and let you know!

florgiulianimdq commented 1 week ago

It didn't chage, here is the output egression results using deltaryff as the criterion

         Predictor       b        b_95%_CI sr2  sr2_95%_CI             Fit        Difference
       (Intercept)   -2.38  [-13.92, 9.15]                                                  
              Edad    0.16   [-0.11, 0.43] .01 [-.02, .03]                                  
   GeneroMasculino   -5.66  [-12.59, 1.27] .01 [-.02, .05]                                  

NivelNivel primario 5.68* [0.87, 10.50] .03 [-.02, .08]
NivelNivel secundario 1.63 [-3.91, 7.17] .00 [-.01, .01]
NivelNivel superior 13.08 [3.71, 22.45] .04 [-.02, .10]
RolEquipo Directivo 3.43 [-1.80, 8.65] .01 [-.02, .04]
R2 = .118

95% CI[.02,.19]

       (Intercept)  -17.56  [-44.42, 9.29]                                                  
              Edad    0.16   [-0.11, 0.44] .01 [-.02, .03]                                  
   GeneroMasculino   -5.17  [-12.31, 1.97] .01 [-.02, .04]                                  

NivelNivel primario 5.68* [0.75, 10.61] .03 [-.02, .08]
NivelNivel secundario 2.01 [-3.68, 7.71] .00 [-.01, .02]
NivelNivel superior 13.86* [4.37, 23.34] .05 [-.01, .11]
RolEquipo Directivo 2.87 [-2.42, 8.17] .01 [-.02, .03]
responsabilidad 0.20 [-5.75, 6.14] .00 [-.00, .00]
extraversion 1.68 [-2.42, 5.78] .00 [-.01, .02]
agradabilidad 0.60 [-4.89, 6.10] .00 [-.00, .00]
neuroticismo -0.34 [-4.26, 3.57] .00 [-.00, .00]
apertura 1.80 [-3.18, 6.78] .00 [-.01, .02]
R2 = .138
Delta R2 = .020 95% CI[.00,.18] 95% CI[-.02, .06]

       (Intercept)   -5.60 [-30.82, 19.63]                                                  
              Edad    0.13   [-0.12, 0.39] .01 [-.01, .02]                                  
   GeneroMasculino   -2.77   [-9.43, 3.89] .00 [-.01, .02]                                  

NivelNivel primario 5.35 [0.72, 9.98] .03 [-.02, .07]
NivelNivel secundario 2.54 [-2.73, 7.80] .00 [-.01, .02]
NivelNivel superior 9.45
[0.47, 18.43] .02 [-.02, .06]
RolEquipo Directivo 3.65 [-1.28, 8.59] .01 [-.02, .04]
responsabilidad -3.24 [-8.90, 2.43] .01 [-.01, .03]
extraversion 1.70 [-2.10, 5.50] .00 [-.01, .02]
agradabilidad 2.60 [-2.53, 7.73] .00 [-.01, .02]
neuroticismo -0.56 [-4.20, 3.08] .00 [-.01, .01]
apertura 0.16 [-4.52, 4.84] .00 [-.00, .00]
deltaCansancio -0.01 [-0.25, 0.24] .00 [-.00, .00]
deltaSTAI -0.44 [-0.76, -0.11] .03 [-.01, .08]
deltaEstres -0.63
[-0.95, -0.31] .07 [.01, .14]
R2 = .279 Delta R2 = .141 95% CI[.10,.33] 95% CI[.05, .23]

       (Intercept)  -10.93 [-36.23, 14.36]                                                  
              Edad    0.08   [-0.18, 0.34] .00 [-.01, .01]                                  
   GeneroMasculino   -2.39   [-9.01, 4.24] .00 [-.01, .01]                                  

NivelNivel primario 5.77* [1.13, 10.41] .03 [-.01, .07]
NivelNivel secundario 2.21 [-3.04, 7.46] .00 [-.01, .02]
NivelNivel superior 6.14 [-2.90, 15.17] .01 [-.01, .03]
RolEquipo Directivo 3.88 [-0.95, 8.71] .01 [-.01, .04]
responsabilidad -3.76 [-9.33, 1.82] .01 [-.01, .03]
extraversion 2.09 [-1.71, 5.89] .01 [-.01, .02]
agradabilidad 3.92 [-1.23, 9.07] .01 [-.01, .04]
neuroticismo 0.23 [-3.42, 3.89] .00 [-.00, .00]
apertura 0.26 [-4.32, 4.84] .00 [-.00, .00]
deltaCansancio 0.02 [-0.23, 0.27] .00 [-.00, .00]
deltaSTAI -0.31 [-0.65, 0.02] .02 [-.02, .05]
deltaEstres -0.53 [-0.86, -0.21] .05 [-.01, .10]
deltaffmq 0.15 [0.00, 0.29] .02 [-.01, .05]
deltascs 0.17 [-0.21, 0.55] .00 [-.01, .02]
deltaProsoc 0.27
[0.03, 0.51] .02 [-.01, .06]
deltaAEF 0.02 [-0.42, 0.46] .00 [-.00, .00]
deltamait 0.71 [-0.89, 2.31] .00 [-.01, .02]
deltaMindset -0.07 [-0.60, 0.46] .00 [-.00, .00]
R2 = .349
Delta R2 = .070* 95% CI[.14,.38] 95% CI[.01, .13]

Note. A significant b-weight indicates the semi-partial correlation is also significant. b represents unstandardized regression weights. sr2 represents the semi-partial correlation squared. Square brackets are used to enclose the lower and upper limits of a confidence interval.