dstanley4 / apatables Goto Github PK
View Code? Open in Web Editor NEWDevelopment version of apaTables R package. Current stable version is on the CRAN.
Home Page: http://dstanley4.github.io/apaTables/
License: Other
Development version of apaTables R package. Current stable version is on the CRAN.
Home Page: http://dstanley4.github.io/apaTables/
License: Other
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.
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
@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).
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
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.
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).
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)
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
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)INDD+INTD+REL_CONT+ADMDIS_CONT+CFOPS_CONT+LNTOTASS_CONT+PROMAR_CONT+LNLIQRAT_CONT+LNINFL_CONT, data=datasetinddiv)
multi.fitinddiv = lm(TQ
multi.fitintdiv = lm(TQINDD+INTD+REL_CONT+ADMDIS_CONT+CFOPS_CONT+LNTOTASS_CONT+PROMAR_CONT+LNLIQRAT_CONT+LNINFL_CONT, data=datasetintdiv)INDD+INTD+REL_CONT+ADMDIS_CONT+CFOPS_CONT+LNTOTASS_CONT+PROMAR_CONT+LNLIQRAT_CONT+LNINFL_CONT, data=datasetlat)
multi.fitlat = lm(TQ
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)
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.
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
If you run lm with no intercept package crashes.
Error in intercept_row$predictor[1] <- reg_table_first$predictor[1] :
replacement has length zero
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
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:
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).
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)
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.
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
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
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")
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?
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.
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.
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!
Hi,
I am running apa.cor.table with show.conf.interval = FALSE but I still get confidence intervals in the table. Is this by design?
Is there any way to format in order to get 3 decimal places in the tables?
Thank you in advanced!
Taylor
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.
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.
Hi, is there a way to include pes and not ges in the ezANOVA table? If not is there a way to define the number of digits that are reported in the ges column?
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
In documentation indicate apa.aov.table won't handle repeated measures.
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...]
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).
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.
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?
The current apa.cor.table()
is fixed to Pearson's r for its method. Would there be any way for you to allow users to choose their desired correlation method among "pearson," "spearman," and "kendall"?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.