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

learn more… | top users | synonyms

1
vote
0answers
7 views

Interpolation of influenza data that conserves weekly mean

For each week, I have the following data: Number of doctors' consultations Number of cases of influenza My goal is to obtain daily data by interpolation (I thought of linear or truncated splines). ...
0
votes
0answers
8 views

How to load arrays with 3 dimension using R2WinBUGS?

Since WinBUGS and R have different ways of organizing data for arrays, how should I organize the data when using R2WinBUGS so that the order is correct? Thanks!
0
votes
0answers
12 views

In R, how to add a one-step-ahead forecast to a timeseries, using nothing but the forecast package?

I am wondering if its possible to add a one-step-ahead forecast to a timeseries, using nothing but the forecast package in R? To avoid lookahead bias, this would involve running ...
2
votes
0answers
15 views

Repeated measures ANOVA in R for non-orthogonal design

I have data from a two-factor within-subjects experiment design where the conditions are not orthogonal. Factor one (Location) has three levels; factor two (Stimulus) has three levels, one of which is ...
1
vote
1answer
42 views

Fisher's method for combing p-values - what about the lower tail?

I have a bunch of independent p-values and now I want to combine them using the Fisher's method. Each of the individual p-values is coming from a one-sided test. I am just a little bit confused about ...
1
vote
1answer
48 views

Why are my prediction intervals a little too narrow?

I'm trying to make a little function to make population-level predictions from a model that includes random effects, which in turn was fit using a package that doesn't support ...
1
vote
1answer
30 views

Why R function Chol() breaks for Hilbert matrices of order n > 12

Is there any theoretical reason that Chol() in R breaks for Hilbert matrix of order greater than 12? Thanks,
1
vote
0answers
20 views

R module for creating plots of prototypical individuals from fitted models?

In order to help interpret fitted models — especially those with interaction terms and non-linear components — I've found it useful to plot predicted values of a dependent variables for what we might ...
-2
votes
0answers
36 views

How do I calculate (age-specific) mortality rates in R? [migrated]

Using data in the following form, in which ways can I calculate the (age-specific) mortality rate in the R programming language? ...
2
votes
0answers
25 views

Variable selection / Dataset reduction for large datasets (in R)

I'm working on a behavoural scorecard modelling exercise, and many of the decisions taken to date have been based on the experience of a consulting credit analyst (whose experience software-wise is ...
2
votes
0answers
17 views

Best practices for dealing with shifting, inconsistent seasonality

This question is related to a previous post I've looked at (Calculation of seasonality indexes for complex seasonality), but deals with more granular data (daily instead of weekly), and transforming ...
1
vote
1answer
26 views

ARIMA and external regressors in SAS and R

So I remember reading somewhere that when we have external regressors, auto.arima cannot make correct predictions for the order of difference for either ...
0
votes
0answers
21 views

Will Pearson correlation work for finding associations in term-document matrix?

Do you think Pearson coefficient can be used to find similar terms in documents? How do you calculate mean for these cases? It does not seem right to me! findAssocs function in tm package uses cor ...
0
votes
0answers
28 views

Reconstructing time series data with missing values from external data source

I have a 100 year time series. But the first 30 years are missing. So I correlated the 70 years that I have with another (100 year) time series to predict back / reconstruct the missing values. For ...
-1
votes
0answers
16 views

Plot specific values on x axis using plot() in R [migrated]

Let's say I have some points: a=c(1.234, 23.332, 3.433, 34.53) b=c(112, 234, 221, 23) I would like to plot them by having "a" on the x axis and "b" on the y ...
0
votes
0answers
33 views

Mapping gini index

In my model, there are 3 players, whose income is function of two arbitrary parameters. Say, ...
-1
votes
0answers
18 views

How to plot a scatter diagram using rpy2 in python [closed]

I have a dataset like below in dictionary format, ...
0
votes
0answers
24 views

NMDS: why is the r-squared for a factor variable so low

I am doing an NMDS ordination. The data come from a number of sites scattered around two lakes. In the plots, I coloured the samples from the two lakes blue and green. There seems to be some pretty ...
0
votes
2answers
71 views

How to interpret the output of the summary method for an lm object in R? [duplicate]

I am using sample algae data to understand data mining a bit more. I have used the following commands: ...
0
votes
0answers
20 views

R: obtaining marginal effects from survreg model [migrated]

Could someone quickly explain how to obtain marginal effects from a weibull duration model of the form: ...
2
votes
0answers
38 views

Procrustes Analysis of 3d point cloud without defined landmarks

I am working with several hundred 3d point clouds generated using a 3d scanner and would like to be able to compare their shapes using something like a procrustes analysis. Instead of manually ...
1
vote
0answers
20 views

Computing $\eta_P^2$ from $\eta_G^2$ generalized eta for G*Power

I am trying to perform a power calculation using G*Power. I need $\eta_P^2$, but the ez package for R gives me $\eta_G^2$. I understand the reasons for it doing this, but I still need $\eta_P^2$ for a ...
1
vote
1answer
39 views

How to output varimax-rotated data in R?

I have ran PCA on 25 variables and selected the top 7 PCs using 'prcomp'. prc <- prcomp(pollutions, center=T, scale=T) I have then done varimax rotation on ...
0
votes
1answer
29 views

Simple Mixed Model with 1 Fixed and 1 Random Effect

I have various datasets I need to analyse regarding soil properties, all in the same fashion, with one fixed effect (which is a position along a transect, indicating different land uses). Now my main ...
2
votes
0answers
34 views

Dummy variables for time series

I'm a new user on R. I'm stuck on my times series research currently with the some questions. Not sure anyone can help me. Dummy variable. I wanted to add more than 1 dummy variable in the model. ...
0
votes
0answers
12 views

Pairs Formula function programming in R, upper, middle lower levels [migrated]

I'm having a difficult time programming the pairs function in r, so i can setup upper, middle and lower panels of correlation, histogram and loess respectively. My panel Data looks like this: ...
1
vote
0answers
14 views

How to specify a path model with exogenous variables jointly affected by an unmeasured variable

I’ve simulated some data consisting of one response variable (‘y’) and two collinear predictor variables (‘Amount’ and ‘MPS’), where collinearity arises from one of two causes: (1) Amount causes MPS, ...
0
votes
0answers
21 views

GLM conditional distribution from R GLM

I want to obtain the full distribution of a Gamma (or Inverse Gaussian) distributed $y_i$ given a vector of $\bar x_i$ that have been used in the linear predictor of a coefficient. Suppose also for ...
0
votes
0answers
4 views

Operating on multiple matrices in a for loop using R [migrated]

I have 1000 matrices named A1, A2, A3,...A1000. In a for loop I would like to simply take the colMeans() of each matrix: ...
0
votes
0answers
18 views

Specifying a correct full model for an unbalanced repeated measures design in R lme4

Recently, I have done a fairly complex experiment, and I am having trouble coming up with a model that is suitable for the data. I have spent a few days reading about, e.g., when random effects should ...
0
votes
0answers
10 views

Change variable name in for loop using R [migrated]

I have a for loop: for (i in 1:10){ Ai=d+rnorm(3)} What I would like to do is have A1, A2,A3...A10 and I have the variable i ...
0
votes
0answers
21 views

Plot normal probability for effect estimates in factorial design in R

I have 2 level Design (DOE) with 4 factors (A,B,C,D). I've already calculated the estimates for each main effect and all the interaction effects. How can I construct the normal probability plot to ...
0
votes
0answers
26 views

Confusion matrix with low incidence rate

I am trying to use a binomial regression to predict customer churn. A reproducible example is below. In the example, there is about 5% latent attrition and customers with a price above 200 have a 15% ...
-4
votes
0answers
14 views

Choosing highest number in vector and knowing its position in R [migrated]

I have a vector in R: y=c(-29.900900, 5.728916, 35.234331, 11.854811, 61.309519, 50.432798, -27.654741, 21.413622, -10.805339, -37.504199) I would like to ...
3
votes
5answers
358 views

Generate three random numbers that sum to 1 in R

I would like to generate three random numbers and then standardize them so that they add up to 1. I would like to repeat this procedure so that in the long run the mode is .33 for each number.
3
votes
0answers
33 views

How to build a model where variance depends on covariate?

I have what I believe is a very simple problem for anyone used to modelling with unequal variances (which I am unfortunately not). I have a dependent variable "totrich" which I want to model as a ...
2
votes
1answer
37 views

Iterative Proportional Fitting in R

The mission I am trying to find a way to do Iterative Proportional Fitting in R. The logic of the procedure is like this: one has a table with e.g. sample distribution of some variables. Let us say ...
0
votes
1answer
41 views

Fit of a normal distribution to a one-dimensional dataset in R

I've got a set of (continuous) values from a measurement, where each object should be either positive or negative, and I know that the values of the "negative" objects should be approximately normally ...
0
votes
0answers
24 views

Formula for lmer() [duplicate]

How does the formula for the lmer function work? Some examples: ...
0
votes
1answer
61 views

First steps learning to predict financial timeseries using machine learning

I am trying to get a grasp on how to use machine learning to predict financial timeseries 1 or more steps into the future. I have a financial timeseries with some descriptive data and I would like to ...
0
votes
1answer
38 views

Randomizing variables to get the best combination for high R-squared values in R

I've been spending quite some time to figure out how I can get the best R squared value from randomization of some values in a linear regression equation. I have allele frequency data and 14 ...
1
vote
2answers
112 views

Forecast total for a year given monthly time series

I have a monthly time series (for 2009-2012 non-stationary, with seasonality). I can use ARIMA (or ETS) to obtain point and interval forecasts for each month of 2013, but I am interested in ...
1
vote
1answer
35 views

Multiple Linear Regression Simulation

I'm new to the R language. I would like to know how to simulate from a multiple linear regression model that fulfills all four assumptions of the regression.
0
votes
1answer
25 views

Exogeneous regressors in auto.arima and using them in forecast function in R

I'm trying to forecast a seasonal time series based on its historical values, and also two more time series (that are seasonal themselves.) I'm trying to use an auto.arima, and I'm going to input ...
3
votes
0answers
38 views

Calculating the area of a confidence ellipse within a certain region

I was wondering if someone had an idea on how to calculate the blue shaded area inside my confidence ellipse. Any suggestions or places to look are greatly appreciated. Also, I am hoping to find a ...
1
vote
1answer
33 views

Expected peak to trough calculation

I am having trouble coding up in R equation 3.1 in the following paper: http://www.intelligenthedgefundinvesting.com/pubs/rb-cb.pdf My function: ...
0
votes
1answer
33 views

Weighted multiple regression in R with prespecified weights

I would like to run a regression of the following form: Y ~ B1*predictor1 + B2*predictor2 + B3*predictor3 I would like to specify ...
2
votes
1answer
71 views

How to forecast hourly data in R

I have hourly login data for a web site. Certain hours of the day for example between 09:00 and 12:00, there are heavy traffic on the site. I would like to forecast the hourly data for about one year. ...
2
votes
0answers
24 views

Generate predictors with fixed predictive validity in R

Let's say I have a dataset: x=rnorm(1000, mean=0, sd=10) I would like to create five variables (a,b,c,d,e) that I can use to ...
1
vote
1answer
26 views

Separate specifications for p and n in a binomial GLM

For a binomial GLM, both the probability and the number of trials are important for each data entry. Using the glm fucntion in R, how do I specify them separately ...

1 2 3 4 5 78