Use this tag for any *on-topic* question that (a) involves `R` either as a critical part of the question or expected answer (b) is not *just* about how to program in `R`.

learn more… | top users | synonyms

94
votes
6answers
66k views

Difference between logit and probit models

What is the difference between the logit and the probit model? I'm more interested here in knowing when to use logistic regression, and when to use probit. If there's any literature which define it ...
79
votes
1answer
36k views

Interpretation of R's lm() output

the help pages in R assume I know what those numbers mean. I don't :) I'm trying to really intuitively understand every number here. I will just post the output and comment on what I found out. There ...
30
votes
4answers
10k views

How to deal with perfect separation in logistic regression?

If you have a variable which perfectly separates zeroes and ones in target variable, R will yield the following "perfect or quasi perfect separation" warning message: ...
14
votes
2answers
3k views

Simulation of logistic regression power analysis - designed experiments

This question is in response to an answer given by @Greg Snow in regards to a question I asked concerning power analysis with logistic regression and SAS ...
31
votes
6answers
13k views

When is it ok to remove the intercept in lm()?

I am running linear regression models and wondering what the conditions are for removing the intercept term of lm()? In comparing results from two different lm ...
8
votes
1answer
5k views

How to interpret type I (sequential) ANOVA and MANOVA?

My primary question is how to interpret the output (coefficients, F, P) when conducting a Type I (sequential) ANOVA? My specific research problem is a bit more complex, so I will break my example into ...
9
votes
4answers
2k views

Obtaining a formula for prediction limits in a linear model

Let's take the following example: set.seed(342) x1 <- runif(100) x2 <- runif(100) y <- x1+x2 + 2*x1*x2 + rnorm(100) fit <- lm(y~x1*x2) This creates a ...
68
votes
21answers
16k views

Resources for learning R [duplicate]

I'm interested in learning R on the cheap. What's the best free resource/book/tutorial for learning R?
51
votes
1answer
8k views

R's lmer cheat-sheet

There's a lot of discussion going on on this forum about the proper way to specify various hierarchical models using lmer. I thought it would be great to have all ...
12
votes
2answers
2k views

What distribution does my data follow?

Let us say that I have 1000 components and I have been collecting data on how many times these log a failure and each time they logged a failure, I am also keeping track of how long it took my team to ...
31
votes
1answer
9k views

Removal of statistically significant intercept term boosts $R^2$ in linear model

In a simple linear model with a single explanatory variable, $\alpha_i = \beta_0 + \beta_1 \delta_i + \epsilon_i$ I find that removing the intercept term improves the fit greatly (value of $R^2$ ...
11
votes
2answers
4k views

How to find a good fit for semi-sinusoidal model in R?

I want to assume that the sea surface temperature of the Baltic Sea is the same year after year, and then describe that with a function / linear model. The idea I had was to just input year as a ...
31
votes
5answers
11k views

Which permutation test implementation in R to use instead of t-tests (paired and non-paired)?

I have data from an experiment that I analyzed using t-tests. The dependent variable is interval scaled and the data are either unpaired (i.e., 2 groups) or paired (i.e., within-subjects). E.g. ...
29
votes
1answer
13k views

How to interpret coefficients in a Poisson regression?

How can I interpret the main effects (coefficients for dummy-coded factor) in a Poisson regression? Assume the following example: ...
3
votes
3answers
2k views

Continuous dependent variable with ordinal independent variable

Given a continuous dependent variable y and independent variables including an ordinal variable X1, how do I fit a linear model in R? Are there papers about this ...
26
votes
3answers
4k views

Box-Cox like transformation for independent variables?

Is there a Box-Cox like transformation for independent variables? That is, a transformation that optimizes the $x$ variable so that the y~f(x) will make a more ...
8
votes
1answer
885 views

Alternatives to one-way ANOVA for heteroskedastic data

I have data from 3 groups of algae biomass ($A$, $B$, $C$) which contain unequal sample sizes ($n_A=15$, $n_B=13$, $n_C=12$) and I would like compare if these groups are from the same population. ...
200
votes
21answers
65k views

Python as a statistics workbench

Lots of people use a main tool like Excel or another spreadsheet, SPSS, Stata, or R for their statistics needs. They might turn to some specific package for very special needs, but a lot of things can ...
24
votes
2answers
17k views

How are the standard errors of coefficients calculated in a regression?

For my own understanding, I am interested in manually replicating the calculation of the standard errors of estimated coefficients as, for example, come with the output of the ...
11
votes
2answers
5k views

Why do lme and aov return different results for repeated measures ANOVA in R?

I am trying to move from using the ez package to lme for repeated measures ANOVA (as I hope I will be able to use custom ...
25
votes
7answers
4k views

How can I efficiently model the sum of Bernoulli random variables?

I am modeling a random variable ($Y$) which is the sum of some ~15-40k independent Bernoulli random variables ($X_i$), each with a different success probability ($p_i$). Formally, $Y=\sum X_i$ where ...
18
votes
4answers
2k views

Good methods for density plots of non-negative variables in R?

plot(density(rexp(100)) Obviously all density to the left of zero represents bias. I'm looking to summarize some data for non-statisticians, and I want to avoid ...
12
votes
2answers
1k views

I'm getting “jumpy” loadings in rollapply PCA in R. Can I fix it?

I have 10 years of daily returns data for 28 different currencies. I wish to extract the first principal component, but rather than operate PCA on the whole 10 years, I want to rollapply a 2 year ...
17
votes
1answer
6k views

Interpreting plot.lm()

I had a question about interpreting the graphs generated by plot(lm) in R. I was wondering if you guys could tell me how to interpret the scale-location and leverage-residual plots? Any comments would ...
22
votes
5answers
9k views

Generate a random variable with a defined correlation to an existing variable

For a simulation study I have to generate random variables that show a prefined (population) correlation to an existing variable $Y$. I looked into the R packages ...
7
votes
2answers
5k views

Using principal component analysis (PCA) for feature selection

I'm new to feature selection and I was wondering how you would use PCA to perform feature selection. Does PCA compute a relative score for each input variable that you can use to filter out ...
9
votes
1answer
4k views

Cross-correlation significance in R

How do you tell if the correlations at different lags obtained from the cross-correlation (ccf function) of two time series are significant.
14
votes
5answers
7k views

Post-hocs for within subjects tests?

What is the preferred method for for conducting post-hocs for within subjects tests? I've seen published work where Tukey's HSD is employed but a review of Keppel and Maxwell & Delaney suggests ...
23
votes
1answer
1k views

Logistic regression in R resulted in Hauck Donner phenomenon. Now what?

I'm trying to predict a binary outcome using 50 continuous explanatory variables (the range of most of the variables is -∞ to ∞). My data set has almost 24,000 rows. When I run glm in R, I get: ...
12
votes
2answers
7k views

Transforming variables for multiple regression in R

I am trying to perform a multiple regression in R. However, my dependent variable has the following plot: Here is a scatterplot matrix with all my variables ...
12
votes
1answer
10k views

Post hoc test after ANOVA with repeated measures using R

I have performed a repeated measures ANOVA in R, as follows: aov_velocity = aov(Velocity ~ Material + Error(Subject/(Material)), data=scrd) summary(aov_velocity) ...
14
votes
4answers
5k views

is psych::principal function still PCA when using rotation?

I have tried to reproduce some research (using PCA) from SPSS in R. In my experience, principal() function from package psych ...
7
votes
1answer
16k views

How to interpret coefficient standard errors in linear regression?

I'm wondering how to interpret the coefficient standard errors of a regression when using the display function in R. For example in the following output: ...
43
votes
4answers
17k views

How to choose nlme or lme4 R library for mixed effects models?

I have fit a few mixed effects models (particularly longitudinal models) using lme4 in R but would like to really master the ...
16
votes
4answers
7k views

Visualizing Likert responses using R or SPSS

I have 82 respondents in 2 groups (43 in Group A and 39 in Group B) that completed a survey of 65 Likert questions each ranging from 1 – 5 (strongly agree - strongly disagree). I therefore have a ...
13
votes
5answers
2k views

Time taken to hit a pattern of heads and tails in a series of coin-tosses

Inspired by Peter Donnelly's talk at TED, in which he discusses how long it would take for a certain pattern to appear in a series of coin tosses, I created the following script in R. Given two ...
4
votes
3answers
723 views

Log or square-root transformation for ARIMA

With the below dataset, I have a series which needs transforming. Easy enough. However, how do you decide which of the SQRT or LOG transformations is better? And how do you draw that conclusion? ...
5
votes
1answer
2k views

Can the scaling values in a linear discriminant analysis (LDA) be used to plot explanatory variables on the linear discriminants?

Using a biplot of values obtained through principal component analysis, it is possible to explore the explanatory variables that make up each principle component. Is this also possible with Linear ...
6
votes
2answers
974 views

dispersion in summary.glm()

I conducted a glm.nb by glm1<-glm.nb(x~factor(group)) with group being a categorial and x being a metrical variable. When I try to get the summary of the ...
3
votes
4answers
262 views

r sequence recognition for univariate data sequence mining

I am looking for a method to detect sequences within univariate discrete data without specifying the length of the sequence or the exact nature of the sequence beforehand (see e.g. Wikipedia - ...
7
votes
1answer
4k views

Wald test in regression (OLS and GLMs): t- vs. z-distribution

I understand that the Wald test for regression coefficients is based on the following property that holds asymptotically (e.g. Wasserman (2006): All of Statistics, pages 153, 214-215): $$ ...
4
votes
2answers
4k views

Test a significant difference between two slope values

The data I have are a regression slope value of y~time, a standard error, an n value and a p value, for a particular species in two different areas. I want to check whether the the regression slope ...
71
votes
21answers
36k views

R vs SAS, why is SAS preferred by private companies?

I learned R but it seems that companies are much more interested in SAS experience. What are the advantages of SAS over R?
28
votes
3answers
5k views

Is it possible to do time-series clustering based on curve shape?

I have sales data for a series of outlets, and want to categorise them based on the shape of their curves over time. The data looks roughly like this (but obviously isn't random, and has some missing ...
6
votes
2answers
17k views

How to statistically compare two time series?

I have two time series, shown in the plot below: The plot is showing the full detail of both time series, but I can easily reduce it to just the coincident observations if needed. My question is: ...
10
votes
4answers
8k views

A non-parametric repeated-measures multi-way Anova in R?

The following question is one of those holy grails for me for some time now, I hope someone might be able to offer a good advice. I wish to perform a non-parametric repeated measures multiway anova ...
5
votes
5answers
862 views

Where can I find useful R tutorials with various implementations?

I'm using R and the manuals on the R site are really informative. However, I'd like to see some more examples and implementations with R which can help me develop my knowledge faster. Any suggestions? ...
12
votes
5answers
7k views

How does one do a Type-III SS ANOVA in R with contrast codes?

Please provide R code which allows one to conduct a between-subjects ANOVA with -3, -1, 1, 3 contrasts. I understand there is a debate regarding the appropriate Sum of Squares (SS) type for such an ...
9
votes
4answers
3k views

Fit a sinusoidal term to data

Although I read this post, I still have no idea how to apply this to my own data and hope that someone can help me out. I have the following data: ...
8
votes
2answers
4k views

Weibull distribution parameters $k$ and $c$ for wind speed data

I have 5 years worth of mean wind speed meteorological data. I want to compare the observed wind speed data against a Weibull distribution on a graph of the probability density distribution. I have ...