GithubHelp home page GithubHelp logo

dstanley4 / apatables Goto Github PK

View Code? Open in Web Editor NEW
54.0 54.0 12.0 7.11 MB

Development version of apaTables R package. Current stable version is on the CRAN.

Home Page: http://dstanley4.github.io/apaTables/

License: Other

R 100.00%

apatables's People

Contributors

dstanley4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apatables's Issues

Omit significance stars

Is there a way to omit significance stars and show only confidence intervals instead? I don’t report p values or stars in my work.

Output of Results in LaTeX Format

I have noticed that LaTeX format is basically already supported when one looks at apa.reg.table function e.g. Line 147

block_out_latex <- rbind(model_label_line_latex, block_out_latex)

Is there any reason that LaTeX is supported but not offered by the public outer function? It would be super helpful to take advantage of this great work also for LaTeX users.

I am using apaTables package version: 2.0.8

apaTables::apa.reg.table not producing correct results

@dstanley4: apaTables::apa.reg.table() does not produce the correct results (in sr2_95%_CI). Is there any issue with the function? Thanks.

library(apaTables)
basic.reg <- lm(sales ~ adverts + airplay, data = album)
apa.reg.table(basic.reg, filename = "Table2_APA.doc", table.number = 2)
#> 
#> MBESS package needs to be installed to calculate R2 confidence intervals.
#> Warning: Unknown or uninitialised column: 'beta'.
#> Warning: Unknown or uninitialised column: 'LLbeta'.
#> Warning: Unknown or uninitialised column: 'ULbeta'.
#> 
#> 
#> Table 2 
#> 
#> Regression results using sales as the criterion
#>  
#> 
#> # A tibble: 6 x 9
#>   Predictor b     `b_95%_CI` beta  `beta_95%_CI` sr2   `sr2_95%_CI` r    
#>   <chr>     <chr> <chr>      <chr> <chr>         <chr> <chr>        <chr>
#> 1 (Interce~ 41.1~ [22.72, 5~ ""    ""            ""    ""           ""   
#> 2 adverts   0.09~ [0.07, 0.~ 0.52  [0.44, 0.61]  .27   [NA, NA]     .58**
#> 3 airplay   3.59~ [3.02, 4.~ 0.52  [0.44, 0.61]  .29   [-999.., -9~ .60**
#> 4 ""        ""    ""         ""    ""            ""    ""           ""   
#> 5 ""        ""    ""         ""    ""            ""    ""           ""   
#> 6 ""        ""    ""         ""    ""            ""    ""           ""   
#> # ... with 1 more variable: Fit <chr>
#> 
#> Note. A significant b-weight indicates the beta-weight and semi-partial correlation are also significant.
#> b represents unstandardized regression weights. beta indicates the standardized regression weights. 
#> sr2 represents the semi-partial correlation squared. r represents the zero-order correlation.
#> Square brackets are used to enclose the lower and upper limits of a confidence interval.
#> * indicates p < .05. ** indicates p < .01.
#> 

Created on 2018-08-24 by the reprex package (v0.2.0).

Merge several results into a single file

Hi David and Jeffrey,
Your apaTables is wonderful!
It would be very useful to me that apaTables present the option to merge several results into the same Word file. For example, correlation and ANOVA Tables. Similar to the SPSS results page.
It could be possible some command in R do this stuff, but I do not know how to do it.
Really, I open the different output files, copy and paste into a single Word file.
Best
Ale

apa.2way.table

is there a bug in apaTables::apa.2way.table?

the code breaks at this point.
iv1 <- as.factor(data[, iv1.name])

iv1 is a Factor named Job in my data
iv1.name is a chr = ""Job""

Thanks.

Thank you and suggestion re multiple tables

Firstly, thank you so much for the addition of apa.knit.pdf, I was saving my tables and sending to kable but the formatting on the table note really didn't work. I am really happy to finally have something that easily works for getting my regressions into latex and the output looks lovely.

Would it be (or is it already?) possible to include two tables together (Year 1 and Year 2 in my case) into one document? In stargazer I can easily look at my outputs side by side (although a lot of extra work is needed to get correct cut-offs, coefficients and p-levels).

error in apa.reg.table ??

I am trying to use apa.reg.table using the CRAN version and am getting the following error message:

Error in if (number_predictors > 1) { : argument is of length zero

Given how simple the code is (below) perhaps there is a bug?

lm_output <- lm(wellbeing ~ esteem , data = data)
apa.reg.table(lm_output, filename = "regression1.doc", table.number = 2)

Error in 2:last_model_number_predictors : argument of length 0

Hello,
I am getting the error "Error in 2:last_model_number_predictors : argument of length 0" in trying to create tables for a relatively simple model.

I see that this is essentially the same problem as was reported here, #13 , but the proposed solutions therein do not help. In addition, I cannot install the development version, as I get the following error:

Error in utils::download.file(url, path, method = method, quiet = quiet, :
cannot open URL 'https://api.github.com/repos/dstanley4/apaTables/tarball/master'

Any thoughts? I have some existing tables that apaTables made with which I'd like to keep the present tables consistent; your assistance would be much appreciated.

Thanks,
Peter

apa.reg.table: Column `LLb` must be length 9 (the number of rows) or one, not 10

I am trying to run the apa.reg.table on the following code:

multi.fitfoc = lm(TQINDD+INTD+REL_CONT+ADMDIS_CONT+CFOPS_CONT+LNTOTASS_CONT+PROMAR_CONT+LNLIQRAT_CONT+LNINFL_CONT, data=datasetfoc)
multi.fitinddiv = lm(TQ
INDD+INTD+REL_CONT+ADMDIS_CONT+CFOPS_CONT+LNTOTASS_CONT+PROMAR_CONT+LNLIQRAT_CONT+LNINFL_CONT, data=datasetinddiv)
multi.fitintdiv = lm(TQINDD+INTD+REL_CONT+ADMDIS_CONT+CFOPS_CONT+LNTOTASS_CONT+PROMAR_CONT+LNLIQRAT_CONT+LNINFL_CONT, data=datasetintdiv)
multi.fitlat = lm(TQ
INDD+INTD+REL_CONT+ADMDIS_CONT+CFOPS_CONT+LNTOTASS_CONT+PROMAR_CONT+LNLIQRAT_CONT+LNINFL_CONT, data=datasetlat)

apa.reg.table(multi.fitfoc, multi.fitinddiv, multi.fitintdiv, multi.fitlat, filename = "APA.xls", table.number = 3)

I get this error message: Column LLb must be length 9 (the number of rows) or one, not 10

What might be the reason and how can the issue be solved? (I have tried both with the latest version of apaTables and the developer one. Nothing works)

Large correlation tables and CIs

I am quite in favor of always reporting confidence intervals with the package functions. However, when a correlation matrix is very large, the number of intervals can become unwieldy and unhelpful. Often, all of the variables are included in such a table for completeness in reporting and not because they form the basis for direct inference (e.g. the correlations among 15 indicators at 4 time points).

For such cases, it would be useful to provide options to summarize CI information or limit the CIs to correlations of interest. For example, show.conf.interval = "note" could provide an approximate summary confidence interval in the table note: “Correlations have a confidence interval margin of error ≈ +/– .12.” show.conf.interval could perhaps also take a named vector of the variables of interest for which to report CIs (e.g., interest might be in correlations with a total score, but facet scales are reported for completeness as well; demographic correlations might be reported for completeness, but not be of substantive interest).

In either of these cases, to discourage dichotomous interpretations, I would say to omit significance stars when CIs are suppressed.

Significance stars up to *** p< .001

I've been using apa.reg.table and apa.cor.table. (Thank you so much, btw!)
I notice that neither shows significance stars for p-values less than .001. (When p < .001 it just gets shown as **)
If this were an option, this would be very useful to me.

Thanks,
Caspar

glm() support

Hello all,

I want to use apaTables with glm() for print logistic regression models.

So that could I use apa.reg.table() with glm? Or is available to alternative methods?

Best,
Seongho

Computation of CIs for standardized regression coefficients

At the moment, CIs for standardized regression coefficients are computed with convert_b_to_beta() which applies b * (sd_pred/sd_crit) to the coefficient and regular CI bounds. However, for the CI, this ignores the sampling variability in ci_crit and sd_pred (if the predictor is random). See:

  • Jones, J. A., & Waller, N. G. (2013). Computing confidence intervals for standardized regression coefficients. Psychological Methods, 18(4), 435-453.
  • Jones, J. A., & Waller, N. G. (2015). The normal-theory and asymptotic distribution-free (adf) covariance matrix of standardized regression coefficients: Theoretical extensions and finite sample behavior. Psychometrika, 80(2), 365-378.
  • Yuan, K.-H., & Chan, W. (2011). Biases and standard errors of standardized regression coefficients. Psychometrika, 76(4), 670-690.

Would be nice to implement maybe the delta method approach, which seems to work well. Also, there is the fungible package, which provides more appropriate SEs (from which the CI can be computed).

apa.cor.table: Ability to specify a second dataframe as an argument

Currently, to get the correlations between two data frames (x, y), one must use apa.cor.table(cbind(x, y)). This is a tad cumbersome and prints out every variable row- and column-wise when not all of them are needed. It would be such a godsend if we could enter a second data frame as an argument.

e.g., in stats::cor(x, y) and Hmisc::rcorr(x,y)

apa.reg.table error related to atomic vectors

Hi!
I recently installed the apaTables package and am very happy with it. I've used the apa.cor.table function and had no problem at all.

Now I tried to use the apa.reg.table function and it gives me the following error:
Error: $ operator is invalid for atomic vectors

The code I used to call the function is this:
bracing_negem3 <- lm(tas3_negem ~ estimation_pers + tas1_negem, data = data_set) apa.reg.table(bracing_negem3, "Table_BracingNegEm3.docx", 2)

When I use is.atomic(bracing_negem3) it tells me that it isn't atomic. So I checked using is.recursive(bracing_negem3) and it is indeed recursive.

I'm using the CRAN version. All my packages are updated and I also tried the developer version, but I keep getting the same error.

Correlation tables confidence interval and M SD columns

Hi David and Jeffrey,
I am very happy to use your R apaTables package.
It would be very useful to me that apaTables present the options for including or not (a) the confidence intervals and, (b) Mean and standard deviation columns in the correlation matrix.
Best
Ale

Spanish language notes

Hi David and Jeffrey,
Your R apaTables package rocks!
It would be very useful to me that apaTables present the option of including Spanish notes for the Tables. If you want I could write the notes for the package.
Best
Ale

Different results between summary() and apa.aov.table()

Hi everyone!
Why do I get different results between summary() and the output from apa.aov.table?
Different sum squares, p values, etc.
Thanks in advance!

Example using goggles
lm_output <- aov(attractiveness ~ gender*alcohol, data = goggles)
summary(lm_output)
apa.aov.table(lm_output, filename = "table_APA.doc")

CIs for repeated measures

Hi
Thanks a lot for your really helpful package!
Is there a way to include the confidence intervals also in the ezanova.table version? Or to read the outcome from the aov() wrapper?

apa.reg.table not printing interactions in table

Hi there. I have a lm object (linear regression with main effects and interactions), and when using apa.reg.table it does not print the interaction terms/values in the table. This happens if I use do something like the following: m1 <- lm(dv ~ iv1 + iv2 * iv3 iv4), or even: m2 <- lm(dv ~ iv1 + iv2 + iv3 +iv4 + iv2iv3 +iv2iv4 + iv3iv4 + iv2iv3iv4. Do you have any suggestions? Thanks.

bootstrapped tables with interaction issue

Hello,

I am having trouble producing a table of bootstrapped regression results with an interaction term; so the model looks like d <-lm(dependent ~ v1*v2, data=x). I get the following error

Error: Assigned data sr2_CI_boot[, c("LL")] must be compatible with existing data.
x Existing data has 2 rows.
x Assigned data has 3 rows.
i Only vectors of size 1 are recycled.

The apa.reg.boot.table works fine with either variable alone in the model, or adding the second variable as an additional coefficient (v1 +v2), but does not permit the above interaction term. I am able to conduct the bootstrap using car package 'Boot' function, but I'd like to use apaTables to report the result.

apa.save not working

Hi there. I am using 2.0.8 and I followed your apa.reg tut. Upon apa.save I am receiving an error msg stating that the apa.save function cannot be found. Any idea what I might be doing wrong? Thanks!

3 decimal places

Is there any way to format in order to get 3 decimal places in the tables?
Thank you in advanced!
Taylor

allow apa.reg.table to show columns with different Ns, different DVs

apa.reg.table seems to assume that multiple lm objects are essentially the same analysis with different blocks of predictor variables included. But its multiple-column layout could be useful in other situations: presenting analyses of multiple dependent variables side by side, or presenting the same analysis on different sets of observations (e.g., in studies with different sets of participants).

At present it will not do those things, giving an error message that the lm objects have different Ns or something to that effect.

beta on apa.reg.table

Hi,

In the examples for the apa.reg.table function there are columns for beta. However, when I run the function I produce no such beta (see example code below). Did you remove the beta column in the latest version of apaTables? The function produces no errors. Thanks

> apaTables::apa.reg.table(models[[1]],models[[2]],models[[3]],filename = file.name)


Regression results using TUG as the criterion
 

   Predictor       b      b_95%_CI sr2  sr2_95%_CI             Fit        Difference
 (Intercept) 10.57** [7.74, 13.39]                                                  
         Age    0.02 [-0.03, 0.08] .02 [-.06, .09]                                  
  GenderMale    0.30 [-1.13, 1.73] .00 [-.03, .04]                                  
   Education   -0.27 [-0.77, 0.23] .03 [-.07, .13]                                  
                                                         R2 = .043                  
                                                   95% CI[.00,.15]                  
                                                                                    
 (Intercept)   4.78*  [0.39, 9.16]                                                  
         Age    0.02 [-0.03, 0.07] .02 [-.05, .08]                                  
  GenderMale    0.12 [-1.17, 1.41] .00 [-.01, .01]                                  
   Education   -0.36 [-0.81, 0.09] .05 [-.06, .16]                                  
         TSK  0.16**  [0.06, 0.26] .21 [-.00, .41]                                  
                                                        R2 = .249* Delta R2 = .206**
                                                   95% CI[.00,.40] 95% CI[-.00, .41]
                                                                                    
 (Intercept)   4.98*  [0.43, 9.52]                                                  
         Age    0.02 [-0.03, 0.07] .02 [-.05, .08]                                  
  GenderMale    0.09 [-1.22, 1.40] .00 [-.01, .01]                                  
   Education   -0.37 [-0.83, 0.09] .05 [-.06, .17]                                  
         TSK  0.16**  [0.06, 0.26] .20 [-.00, .41]                                  
   `I Total`   -0.72 [-4.33, 2.88] .00 [-.03, .03]                                  
                                                        R2 = .252*   Delta R2 = .003
                                                   95% CI[.00,.38] 95% CI[-.03, .03]
                                                                                    

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.
* indicates p < .05. ** indicates p < .01.

Enhancement request

Love apaTables!

As an enhancement request, I would suggest adding the equivalent of the corrr:focus() function to allow only a portion of the correlation table to be displayed and formatted in APA.

Thanks for the consideration!
Bryan

apa.cor.table footnote misinterprets 95% CIs

First, let me say that this package is terrific! But...in the footnote of apa.cor.table, 95% CIs are described as "a plausible range of population correlations that could have caused the sample correlation (Cumming, 2014)." Cumming may have said this, but this misrepresents what the 95% CI actually is. If a statement is to be made, it might be that "intervals of this nature from similar random samples will capture the population parameter 95% of the time." See a related commentary on Cummming here: https://scholar.princeton.edu/sites/default/files/slinden/files/psychologist_0.pdf

The way to get a range of plausible population correlations, as described, is to be a Bayesian :)

[also, the statement that population correlations could have 'caused' a sample correlation seems a bit off, but that's sort of a side issue...]

apa.reg.boot.table - specification of bootstrapping approach

The documentation of apa.reg.boot.table is missing information on the the type of bootstrapping approach [e.g., percentile or bias-corrected, accelerated percentile (BCa)]. The table note would also benefit from this information.

I'm unsure about the approach that is currently used and would be grateful for this information. Based on the source code, I suspect it might be percentile intervals. If that's the case, adding BCa intervals would be great, since they seem to perform somewhat better than percentile intervals (see e.g., https://socialsciences.mcmaster.ca/jfox/Books/Companion-2E/appendix/Appendix-Bootstrapping.pdf).

Regression Table & Factors

I really like the package. I ran into a small problem when I tried to create a regression table for an equation where one variable was a factor (and so dummy coded). I received the following error.

Error in cor.test.default(dv.in, cur.pred) : 'y' must be a numeric vector

The same model without the factor variable worked great.

I know that I can create my own dummy codes and avoid the issue, but it would also be handy to use factors in the models.

apa.reg.table with blocks of continuous and categorical predictors

Thanks a ton for the great package. I was wondering whether it's possible to enter a block with continuous predictors and a block with categorical predictors into apa.reg.table.

Example:

library(tidyverse)
library(apaTables)

dat <-
  tibble(
    dv = rnorm(10, 0, 1),
    iv = rnorm(10, 0, 1),
    cat = rep(c("A", "B"), each = 5)
  )

block1 <- lm(dv ~ iv, data = dat)
block2 <- lm(dv ~ iv + cat, data = dat)

apa.reg.table(block1, block2, filename = "table.doc")

This results in an error message because block2 is a list that itself contains a list with the contrasts for cat. block1 does not have those contrasts, resulting in different numbers of list elements:

Error in rbind(deparse.level, ...) : 
  numbers of columns of arguments do not match

Any way to make this work other than creating numeric 0/1 variables for each dummy contrast?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.