R is an open source programming language and software environment for statistical computing and graphics.

learn more… | top users | synonyms

37
votes
5answers
14k views

Difference between logit and probit models

Can anybody please tell me 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 ...
43
votes
1answer
13k 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 ...
19
votes
5answers
6k 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. ...
124
votes
20answers
34k 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 ...
47
votes
19answers
7k views

Resources for learning R

I'm interested in learning R on the cheap. What's the best free resource/book/tutorial for learning R?
29
votes
1answer
2k 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 the information in one place. A ...
4
votes
1answer
2k 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 ...
25
votes
6answers
5k 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 ...
11
votes
5answers
4k 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 ...
21
votes
1answer
3k 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$ ...
9
votes
2answers
3k 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 ...
12
votes
4answers
3k 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
4answers
760 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 ...
6
votes
2answers
528 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 ...
11
votes
4answers
3k 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 ...
11
votes
4answers
4k 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 ...
29
votes
3answers
10k 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 models and the code that goes with them. However, before diving in with ...
21
votes
3answers
2k 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 ...
14
votes
1answer
412 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: ...
5
votes
3answers
476 views

What to make of explanatories in time series?

Having worked mostly with cross sectional data so far and very very recently browsing, scanning stumbling through a bunch of introductory time series literature I wonder what which role explanatory ...
17
votes
8answers
3k 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 ...
5
votes
3answers
5k 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 ...
15
votes
9answers
2k views

Time series for count data, with counts < 20

I recently started working for a tuberculosis clinic. We meet periodically to discuss the number of TB cases we're currently treating, the number of tests administered, etc. I'd like to start ...
19
votes
1answer
7k 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: ...
13
votes
1answer
1k views

Manually calculated $R^2$ doesn't match up with randomForest() $R^2$ for testing new data

I know this is a fairly specific R question, but I may be thinking about proportion variance explained, $R^2$, incorrectly. Here goes. I'm trying to use the ...
7
votes
6answers
2k views

Estimating a distribution based on three percentiles

What methods can I use to infer a distribution if I know only three percentiles? For example, I know that in a certain data set, the fifth percentile is 8,135, the 50th percentile is 11,259, and the ...
7
votes
4answers
2k 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 ...
6
votes
1answer
5k 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) ...
2
votes
1answer
469 views

Goodness of fit test for a mixture in R

I just estimated the parameters for a mixture of two gaussians with different means and different sigmas, I would like to test if the data adjusts well to the explicit form of the mixture, do I ...
6
votes
1answer
2k 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.
7
votes
2answers
1k views

How to deal with perfect separation in logistic regression?

If you have variable which perfecly separates zeroes and ones in target variable, R will yield the following "perfect or quasi perfect separation" warning message: ...
3
votes
1answer
151 views

Interpreting interaction terms in logit regression with categorical variables

I have data from a survey experiment in which respondents were randomly assigned to one of four groups: ...
2
votes
1answer
1k views

Two-stage clustering in R

Is it possible to do 2-stage cluster analysis in R? Can anybody provide me resource on it?
4
votes
1answer
574 views

Graphing a Probability Curve for a Logit Model With Multiple Predictors

I have the following probability function: $$\text{Prob} = \frac{1}{1 + e^{-z}}$$ where $$z = B_0 + B_1X_1 + \dots + B_nX_n.$$ My model looks like $$\Pr(Y=1) = \frac{1}{1 + \exp\left(-[-3.92 + ...
2
votes
4answers
148 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 - ...
1
vote
0answers
196 views

Can I include year as an independent variable in this nested logistic regression design?

I want to make a nested logistic regression in R with the package mlogit. I would like to test how producer's decision to enter organisations (14 organisations) or not is affected by different ...
45
votes
14answers
2k views

Complete substantive examples of reproducible research using R

The Question: Are there any good examples of reproducible research using R that are freely available online? Ideal Example: Specifically, ideal examples would provide: The raw data (and ideally ...
22
votes
5answers
4k views

Time series 'clustering' in R

I have a set of time series data. Each series covers the same period, although the actual dates in each time series may not all 'line up' exactly. That is to say, if the Time series were to be read ...
29
votes
6answers
29k views

How to summarize data by group in R?

I have R data frame like this: ...
22
votes
23answers
3k views

What R packages do you find most useful in your daily work?

Duplicate thread: I just installed the latest version of R. What packages should I obtain? What are the R packages you couldn't imagine your daily work with data? Please list both general and ...
14
votes
2answers
1k views

Aggregating results from linear model runs R

Since regression modeling is often more "art" than science, I often find myself testing many iterations of a regression structure. What are some efficient ways to summarize the information from these ...
17
votes
4answers
3k views

What book is recommendable to start learning statistics using R at the same time?

Books to Learn Statistics using R What exactly is the book I'm looking for. What I am looking for is a book that teaches you statistics while using R to give you hands-on experience and thus end up ...
7
votes
2answers
6k views

Repeated measures ANOVA with lme in R for two within-subject factors

I'm trying to use lme from the nlme package to replicate results from aov for repeated ...
4
votes
5answers
417 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
4answers
786 views

LOESS that allows discontinuities

Is there a modelling technique like LOESS that allows for zero, one, or more discontinuities, where the timing of the discontinuities are not known apriori? If a technique exists, is there an ...
9
votes
2answers
2k views

How to deal with collinearity issue when performing variable selection?

I've got a dataset with 9 continuous independent variables that I'm trying to select between to fit a model to a single percentage (dependent) variable, Score. ...
17
votes
3answers
699 views

Why does including latitude and longitude in a GAM account for spatial autocorrelation?

I have produced generalized additive models for deforestation. To account for spatial-autocorrelation, I have included latitude and longitude as a smoothed, interaction term (i.e. s(x,y)). I've based ...
7
votes
3answers
7k views

Logistic Regression in R (Odds Ratio)

I'm trying to undertake a logistic regression analysis in R. I have attended courses covering this material using STATA. I am finding it very difficult to replicate ...
5
votes
3answers
838 views

Outliers spotting in time series analysis, should I pre-process data or not?

My question builds on a previous post on outlier detection in generic time series, and specifically on the answer provided by the always great Rob H. I work for a small-sized manufacturing company ...
4
votes
1answer
2k views

Type III sum of squares from SAS and R

I'm analyzing data from an unbalanced factorial experiment both with SAS and R. Both SAS and ...

1 2 3 4 5 11