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 use `R`.

learn more… | top users | synonyms

40
votes
5answers
6k views

Alternatives to logistic regression in R

I would like as many algorithms that perform the same task as logistic regression. That is algorithms/models that can give a prediction to a binary response (Y) with some explanatory variable (X). ...
8
votes
3answers
5k views

R package for fixed-effect logistic regression

I'm looking for an R package for estimating the coefficients of logit models with individual fixed-effect (individual intercept) using Chamberlain's 1980 estimator. ...
5
votes
1answer
2k views

Using [R] to connect to a Web Service [closed]

I have a web service, which returns a dataset, and I would like to query it from the [R] statistical package. I'd like to know how (or if) this can be done and also how to load the first datatable, of ...
5
votes
4answers
4k views

How to get Sphericity in R for a nested within subject design?

Thank you for reading. I am trying to get sphericity values for a purely within subject design. I have been unable to use ezANOVA, or Anova(). Anova works if I add a between subject factor, but I have ...
9
votes
2answers
4k views

Quickly evaluate (visually) correlations between ordered categorical data in R?

I'm looking for correlations between the answers to different questions in a survey ("umm, let's see if answers to question 11 correlate with those of question 78"). All answers are categorical (most ...
5
votes
1answer
2k views

Checking assumptions for random effects in nested mixed-effects models in R / S-Plus

I am modelling a nested mixed-effects model with just the intercept in the random part, of the form: ...
12
votes
2answers
22k views

Interpretation of biplots in principal components analysis in R

I came across this nice tutorial: A Handbook of Statistical Analyses Using R. Chapter 13. Principal Component Analysis: The Olympic Heptathlon on how to do PCA in R language. I don't understand the ...
15
votes
5answers
9k views

How do I decide what span to use in LOESS regression in R?

I am running LOESS regression models in R, and I want to compare the outputs of 12 different models with varying sample sizes. I can describe the actual models in more details if it helps with ...
56
votes
14answers
3k 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 ...
3
votes
3answers
2k views

Can you use normal correlation for vectors with only 2 (or 3), ordered, levels?

When one wants to compute the correlation of two vectors of a continues variables, one uses pearson (or spearman) correlation. But what should (can) one use for the case of two vectors with 2 (or 3) ...
11
votes
2answers
2k views

How to simulate a custom power analysis of an lm model (using R)

Following to the recent questions we had here. I was hopping to know if anyone had come across or can share R code for performing a custom power analysis based on simulation for a linear model? ...
7
votes
2answers
500 views

Hypothesis testing that one time-series of a measure of entropy doesn't belong to a population

Disclaimer: I'm a software engineer, not a statistician, so please forgive any blunt error :-) I have a set of time-series "curves", each measuring the entropy of a given artifact. Now, I'm standing ...
8
votes
2answers
6k views

How do I vertically stack two graphs with the same x scale, but a different y scale in R?

Greetings, Currently I'm doing the following in R: ...
5
votes
4answers
827 views

FA: Choosing Rotation matrix, based on “Simple Structure Criteria”

One of the most important issues in using factor analysis is its interpretation. Factor analysis often uses factor rotation to enhance its interpretation. After a satisfactory rotation, the rotated ...
11
votes
2answers
2k views

What would a confidence interval around a predicted value from a mixed effects model mean?

I was looking at this page and noticed the methods for confidence intervals for lme and lmer in R. For those who don't know R, those are functions for generating mixed effects or multi-level models. ...
5
votes
2answers
1k views

Using bootstrap for glm coefficients variance estimation (in R)

I am fitting a GLM model (in R), and would like to get an estimation of the variability of the coefficients estimated by the model. If I understand it correctly the method to use in such a case is ...
6
votes
5answers
371 views

How to start an analysis of keywords from a bibliography and detect correlations?

(I'm a bit outside my comfort zone, so apologies if this is badly worded, or off-topic) I have a bibliographic database, containign details of about 1200 different papers, books, web sites etc, all ...
6
votes
2answers
555 views

Significant Difference between two network graphs

I am taking the time to learn how to analyze networks and want to test if there are differences between two networks over time. Since I am new to R and networks in general, I am hoping to get some ...
11
votes
6answers
4k views

How to find summary statistics for all unique combinations of factors in a data.frame in R?

I want to calculate a summary of a variable in a data.frame for each unique combination of factors in the data.frame. Should I use plyr to do this? I am ok with using loops as opposed to apply() ; so ...
6
votes
2answers
2k views

Export/format output from pairwise.t.test to LaTeX

I am trying to format the output from pairwise.t.test into LaTeX, but have not found a way of doing this. Has anyone got any suggestions? EDIT: As this is a one-time only report where I do need to ...
5
votes
1answer
1k views

Tangency portfolio in R

I am trying to solve for an efficient portfolio in R. How do I translate my constraints for a tangency point for 2 risky asset portfolio, and a given risk free rate to R solve.QP function? So ...
7
votes
10answers
2k views

I just installed the latest version of R. What packages should I obtain?

Duplicate thread: What R packages do you find most useful in your daily work? Are there any R packages that are just plain good to have, regardless of the type of work you are doing? If so, what are ...
5
votes
2answers
1k views

How to fit a negative binomial distribution in R while incorporating censoring

I need to fit $Y_{ij} \sim NegBin(m_{ij},k)$, i.e. a negative binomial distribution to count data. However, the data I have observed are censored - I know the value of $y_{ij}$, but it could be more ...
243
votes
25answers
84k 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 ...
4
votes
3answers
1k views

Recreating traditional null hypothesis testing with Bayesian methods

I am trying to recreate (in R) a frequentist hypothesis testing in Bayesian from, by calculating Bayes factors of the null (H0) and alternative (H1) models. The model is simply a simple linear ...
7
votes
2answers
6k views

Is it possible to directly read CSV columns as categorical data?

I need to analyze with R the data from a medical survey (with 100+ coded columns) that comes in a CSV. I will use rattle for some initial analysis but behind the scenes it's still R. If I read.csv() ...
31
votes
5answers
22k views

What do the residuals in a logistic regression mean?

In answering this question John Christie suggested that the fit of logistic regression models should be assessed by evaluating the residuals. I'm familiar with how to interpret residuals in OLS, they ...
2
votes
1answer
628 views

Mixed regression models and custom link functions in R?

It seems like the current revision of lmer does not allow for custom link functions. If one needs to fit a logistic linear mixed effect model with a custom link function what options are available ...
5
votes
1answer
504 views

How could I predict the results of a simple card game?

I want to predict the results of a simple card game, to judge on average, how long a game will last. My 'simple' game is; Cards are dealt from a randomised deck to n players (typically 2-4) Each ...
6
votes
3answers
592 views

Visualizing two scalar variables over time

What would be the best way to display changes in two scalar variables (x,y) over time (z), in one visualization? One idea that I had was to plot x and y both on the vertical axis, with z as the ...
4
votes
2answers
4k views

How can I obtain some of all possible combinations in R?

Sometimes I want to do an exact test by examining all possible combinations of the data to build an empirical distribution against which I can test my observed differences between means. To find the ...
10
votes
4answers
9k 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
3answers
981 views

How can one speed up this correlation calculation in R without multicore?

I have a colleague who calculates correlations in which one set of scores for a subject (e.g. 100 scores) is correlated with another set of scores for that same subject. The resulting correlation ...
1
vote
2answers
413 views

What code would you put before/after your R session?

R allows us to put code to run in the beginning/end of a session. What codes would you suggest putting there? I know of three interesting examples (although I don't have "how to do them" under my ...
6
votes
1answer
1k views

Why does AIC formula in R appear to use one extra parameter than expected?

I'll use an example so that you can reproduce the results ...
4
votes
2answers
619 views

R command for stcox in Stata

What is the equivalent command in R for the stcox command in Stata?
2
votes
2answers
840 views

Column Means Significance Tests in R

New to the site. I am just getting started with R, and want to replicate a feature that is available in SPSS. Simply, I build a "Custom Table" in SPSS with a single categorical variable in the ...
1
vote
3answers
170 views

How can I get R to stop autocompleting my quotes/parens?

When I type a left paren or any quote in the R console, it automatically creates a matching one to the right of my cursor. I guess the idea is that I can just type the expression I want inside without ...
0
votes
2answers
1k views

R lrm model with no predictors

I am creating multiple logistic regression models using lrm from Harrell's Design package in R. One model I would like to make is the model with no predictors. For example, I want to predict a ...
24
votes
5answers
6k views

Any suggestions for making R code use multiple processors?

I have R-scripts for reading large amounts of csv data from different files and then perform machine learning tasks such as svm for classification. Are there any libraries for making use of multiple ...
23
votes
6answers
7k views

Is PCA followed by a rotation (e.g. varimax) still PCA?

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

How can one empirically demonstrate in R which cross-validation methods the AIC and BIC are equivalent to?

In a question elsewhere on this site, several answers mentioned that the AIC is equivalent to leave-one-out (LOO) cross-validation and that the BIC is equivalent to K-fold cross validation. Is there ...
15
votes
5answers
9k 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 ...
14
votes
2answers
2k views

How does random forest generate the random forest

I am not an expert of random forest but I clearly understand that the key issue with random forest is the (random) tree generation. Can you explain me how the trees are generated? (i.e. What is the ...
7
votes
4answers
658 views

Why is the average of the highest value from 100 draws from a normal distribution different from the 98th percentile of the normal distribution?

Why is the average of the highest value from 100 draws from a normal distribution different from the 98% percentile of the normal distribution? It seems that by definition that they should be the ...
16
votes
9answers
3k 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 ...
74
votes
21answers
21k 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?
33
votes
3answers
9k views

Clojure versus R: advantages and disadvantages for data analysis

I had a plan of learning R in the near future. Reading another question I found out about Clojure. Now I don't know what to do. I think a big advantage of R for me is that some people in Economics ...
5
votes
5answers
1k 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? ...
27
votes
25answers
8k 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 ...