The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [r]

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.

20,788 questions
Filter by
Sorted by
Tagged with
129 views

How to pass character strings to R from IML Studio

If I define a function in IML: start func(a); submit a / R; print(&a); endsubmit; finish; and run it: ...
75k views

How to use weights in function lm in R?

Could anyone offer some pointers on how to use the weights argument in R's lm function? Say, for instance you were trying to ...
57k views

How to change data between wide and long formats in R? [closed]

You can have data in wide format or in long format. This is quite an important thing, as the useable methods are different, depending on the format. I know you have to work with ...
1k views

Calculating hourly volatility and peak-to-average ratio in R

I have network traffic data in the following for for each hour of a ten day period as follows in a R dataset. ...
4k views

R/Stata package for zero-truncated negative binomial GEE?

this is my first post. I'm truly grateful for this community. I am trying to analyze longitudinal count data that is zero-truncated (probability that response variable = 0 is 0), and the mean != ...
134 views

How to store checks of gradient algorithm in a matrix using R?

I would like to check different gradient algorithms. For example: ...
15k 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 ...
20k views

Statistical methods to more efficiently plot data when millions of points are present?

I find R can take a long time to generate plots when millions of points are present - unsurprising given that points are plotted individually. Furthermore, such plots are often too cluttered and dense ...
12k views

How to graphically compare predicted and actual values from multivariate regression in R?

I'm trying to write a function to graphically display predicted vs. actual relationships in a linear regression. What I have so far works well for linear models, but I'd like to extend it in a few ...
594 views

RNG, R, mclapply and cluster of computers

I'm running a simulation on R and a cluster of computers and have the following problem. On each of X computers I run: ...
25k views

Setting knots in natural cubic splines in R

I have data with many correlated features, and I want to start by reducing the features with a smooth basis function, before running an LDA. I'm trying to use natural cubic splines in the ...
3k views

How to calculate centrality measures in a 4 million edge network using R?

I have a CSV file with 4 million edges of a directed network representing people communicating with each other (e.g. John sends a message to Mary, Mary sends a message to Ann, John sends another ...
37k views

How to aggregate by minute data for a week into hourly means?

How would you get hourly means for multiple data columns, for a daily period, and show results for twelve "Hosts" in the same graph? That is, I'd like to graph what a 24 hour period looks like, for a ...
3k views

Combine multiple boxplots in a lattice

I have a data-table that has about 26000 rows and about 35 columns. The columns are paired, so the values in columns 6 and 7 (for example) are related to each other, so are 8 and 9 and so on. There ...
9k views

Using the stats package in R for kmeans clustering

I'm having difficulty understanding one or two aspects of the cluster package. I'm following the example from Quick-R closely, but don't understand one or two aspects of the analysis. I've included ...
5k views

Poisson distribution and statistical significance

Lets say I have a website which gets 100 hits per day (mu = 100). Yesterday my website got 130 hits (x = 130). If I assume a Poisson distribution, then the probability of getting 130 hits is: ...
2k views

Multistage sampling in R

I've got a dataset similar to this: ...
13k views

What are the text-mining packages for R and are there other open source text-mining programs?

Can you recommend a text mining package in R that can be used against large volumes of data? Secondly, is there a GUI available for any of the text mining packages in R? Thirdly, is there another open ...
2k views

Calculating confidence interval for average hospital length of stay, case-mix adjusted, in R

I'm looking for sample R code, or pointers to sample R code for the following. (Gentle) critique of the approach would also be appreciated. I'm not a statistician and I'm pretty new to R. I have ...
10k views

What is the difference between using aov() and lme() in analyzing a longitudinal dataset?

Can anyone tell me the difference between using aov() and lme() for analyzing longitudinal data and how to interpret results ...
14k views

Understanding comparisons of clustering results

I'm experimenting with classifying data into groups. I'm quite new to this topic, and trying to understand the output of some of the analysis. Using examples from Quick-R, several ...
2k views

Analysing wind data with R

Hi i am analaysing wind data for estimating energy from a wind turbine. I have taken 10 years of wind data and graphed a histogram; my second stage was to fit a Weibull distribution to the data. I ...
2k views

Is there an anova procedure that doesn't assume equal variance?

When conducting a t-test we can always use a Welch approximation of the df, and let go of the assumption of equal variances. Is there something similar for (even one way) anova? (any R ...
1k views

Non-linear regression fails to converge, but fit appears good

I'm fitting a 4 parameter nonlinear regression model to multiple datasets, some of which fail to converge, however, the parameters output after a failure provide a fit that looks good, if not ...
425 views

Spline function with unknown knots

Hello everybody on the site, Do any of you know whether R has a package/routine for estimating spline function with unknown number of knots? Thank in advance.
3k views

Bayesian additive regression trees (BART) for classification analysis of gene expression data

I am interested in applying Bayesian additive regression trees (BART) for classification analysis of gene expression data. I am relatively new to R (and Bioconductor packages) and I am unable to find ...
22k views

Analysis of covariance in R

How do you carry out analysis of covariance using R? How do you interpret the results? A practical example will be highly appreciated.
1k views

How can I effectively summarize and visualize time series of employee activities?

I am managing many people entering data into a database. I have a log of user, date, time, table, and action that each person makes: ...
8k views

GLMNET or LARS for computing LASSO solutions?

I would like to get the coefficients for the LASSO problem $$||Y-X\beta||+\lambda ||\beta||_1.$$ The problem is that glmnet and lars functions give different answers. For the glmnet function I ask ...
515 views

Error creating parser in readHTMLTable

readHTMLTable seems pretty robust, but when I try to use it on this page, I get an error. Any ideas what it means or how I could get around it? The page's biggest table is nested inside another ...
4k views

How to obtain in R a good formula for glm (general linear models) to predict a binomial variable?

Is there a package or library that can help me suggest a formula given the independent variables which will work well in glm, for example this formula can be something like x^2+log(y)+Z, it does not ...
4k views

Number of trials required from a binomial distribution to get the desired odds

This question may have been asked before, but I couldn't find it. So, here goes. From about 3000 data points that can be characterized as "wins" or "losses" (binomial), it turns out that there are ...
638 views

Repeated measures using R [closed]

How do I carry out a repeated measures analysis using R?
15k views

How do I fit a multilevel model for over-dispersed poisson outcomes?

I want to fit a multilevel GLMM with a Poisson distribution (with over-dispersion) using R. At the moment I am using lme4 but I noticed that recently the ...
972 views

Documented/reproducible examples of successful real-world applications of econometric methods?

This question might sound very broad, but here is what I am looking for. I know there are many excellent books about econometric methods, and many excellent expository articles about econometric ...
195 views

Function timings in the Matrix package

In order to test the Matrix package in R, I ran the following piece of code: ...
737 views

Aggregating results from Arima runs R

/edit: To clarify: The mtable function from the memisc package does exactly what I need, but unfortunately does not work with arima models. Similar to this question: I have multiple Arima models, ...
2k views

How to pull data formatted for Matlab into R?

I just ran a vendor-supplied program that converts data from their proprietary binary format to what they call a "Matlab format". There are two resulting files from the conversion, a "filename.dat" ...
12k views

Simulation of ARIMA (1,1,0) series

I have fitted the ARIMA models to the original time series, and the best model is ARIMA(1,1,0). Now I want to simulate the series from that model. I wrote the simple AR(1) model, but I couldn't ...
2k views

The code variable in the nlm() function

In R there is a function nlm() which carries out a minimization of a function f using the Newton-Raphson algorithm. In particular, that function outputs the value of the variable code defined as ...
3k views

How to do a logistic regression with the results of different factor analysis methods

I have a large amount of variables (24) to predict a Y/N value, and I would like help for writting a procedure that automatically tries the different results of the factor selection to see how good ...
32k views

zscore function in R [closed]

I am unable to get the zscore function to work. When I try to call it, I get the following error: ...
9k views

Calculating p-value from an arbitrary distribution

I hope this isn't a silly question. Let's say I have some arbitrary continuous distribution. I also have a statistic, and I'd like to use this arbitrary distribution to get a p-value for this ...
2k views

How can I speed up calculation of the fixed effects in a GLMM?

I'm doing a simulation study which requires bootstrapping estimates obtained from a generalized linear mixed model (actually, the product of two estimates for fixed effects, one from a GLMM and one ...
3k views

How could a Tukey HSD test be more signif then the uncorrected P value of t.test?

I came by the post "Post-hoc Pairwise Comparisons of Two-way ANOVA" (responding to this post), which shows the following: ...
14k views

Plotting a heatmap given a dendrogram and a distance matrix in R

I have dendrogram and a distance matrix. I wish to compute a heatmap -- without re-doing the distance matrix and clustering. Is there a function in R that permits this?
6k views

Split-Plot ANOVA: model comparison tests in R

How can I test effects in a Split-Plot ANOVA using suitable model comparisons for use with the X and M arguments of ...
6k 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 ...