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

0
votes
1answer
5 views

Model Formula with deflator

I'm having difficulties to find the right model formula for my model: $Y_i=a+bX_i$ where Y and X are both deflated by another variable y1/def ~ x1/def +x2/def ...
0
votes
0answers
3 views

Predicting whether a potential sale will be won or lost

I am currently working on a project using a sales system and trying to come up with a way to use the current pipeline of potential sales to predict the amount of product that will be sold in the ...
0
votes
0answers
9 views

including interactions in a mixed linear model in R (lme)

I'm trying to test for the effect of soil moisture on transpiration rates. I have plot-level data for 18 plots in 6 different stands of trees (3 plots x 6 stands). I want to treat "stand" as a random ...
0
votes
1answer
18 views

Non-significant factors after stepwise regression

I have run a stepwise regression on R. However, the summary of the final model includes some factors that are not significant. Why have these factors not been removed? Should I remove these from my ...
0
votes
0answers
20 views

Time varying coefficient time series [on hold]

I have a data set which is the exchange rate of USD and GBP from 2007-01-07 to 2014-06-06. I used the derivatives of a probability density to estimated the optimal bandwidth h = 0.04071872. I want to ...
4
votes
1answer
36 views

Model with non-linear transformation

I don't understand this concept well and need help. I was choosing whether to use a linear model or apply a non-linear transformation in my model formula. To do a diagnostic, I quickly plotted my ...
1
vote
1answer
35 views

K means clustering inadequate in determining extreme regions in R

I want to identify the regions that are considerably higher than the highest cluster. (The obvious regions which should be identified as their own clusters, notably at the x coordinate ~10 e+07. How ...
0
votes
0answers
5 views

Simulation of a nested demand structure, depending upon price and time, following a poisson process

Suppose I sell a product to prices $p\in \{50,100,200\}$ to different points in time $t\in \{1,2,3\}$. Thus a poisson distributed random variable $Y_{t,i} \sim \text{Poi}\left(\lambda\left( ...
0
votes
0answers
15 views

Create correlation map [on hold]

I'm aware that you have a post on almost exactly the same topic, but after many trials I failed to run (or plot?) it successfully. When running ...
0
votes
0answers
12 views

Missing Value in Commodities Prices

I am trying to model the prices of four energetic commodities with ARIMA models in R. Unfortunately the price series is not regular, as for some days, like Christmas, no price is given. My series is ...
0
votes
1answer
39 views

identify different points

I have a large scatterplot, with about 100,000 (x,y) points. The x coordinate is the set of numbers from (1 to ~100,000) - in other words, no 2 points have the same x-coordinate. The y is mostly ...
1
vote
1answer
17 views

How are error terms calculated for moving average model in R [duplicate]

For an ARIMA (0,0,1) model, I understand that R follows the equation: xt = mu + e(t) + theta*e(t-1) (Please correct me if I am wrong) I assume e(t-1) is same as the residual of the last observation. ...
0
votes
0answers
14 views

How to make IPF code faster and more concise in R

Iterative proportional fitting is a way of adjusting 'internal cells' in a multidimensional matrix to optimise fit. It is also known as 'raking' and can be seen as a subset of 'entropy maximisation'. ...
0
votes
1answer
38 views

How to translate R to SQL for a Cox Proportional Hazards model?

I have built a cox model in R using the coxph function in the survival package, and now I need to replicate the model in SQL for scoring. From my understanding, the model has the form described on ...
0
votes
0answers
18 views

Errors when fitting a SARIMAX model in R

Currently working on big data sets, I would like to fit a SARIMAX model to it in order to forecast future values. Here are my questions : Q1. As a matter of information, does anybody know how does R ...
0
votes
0answers
14 views

Label positioning issues using R's base plotting system [on hold]

I would like to resolve label positioning issues in the plot shown below by using R's base plotting system. I realise that this question is in/directly related to a question asked at ...
0
votes
0answers
15 views

Conditional Inference Trees in R

Consider the following data set test with binary outcome variable z and predictor variables a,b,c. ...
0
votes
0answers
16 views

Assessing the effect of related variables using lmer in R

I am trying to run a model to describe the rate of water table drawdown in the soil. The predicted variable is rate, and I am interested in the effect of two categorical variables: (1) if the water ...
1
vote
1answer
23 views

What does y argument do in chisq.test in R?

The chisq.test function in R includes a y = argument, which is to NULL by default. The help ...
1
vote
1answer
26 views

How to choose the right distance matrix for clustering?

I am attempting simple Ward type clustering. However, the R package is proving several choices to use for the distance matrix. I am wondering how I am supposed to determine the right distance matrix ...
0
votes
0answers
26 views

R function which uses innovations algorithm?

I can't seem to find much info on the following: I have a dataset D at time t which I use to fit an ARIMA model. I forecast the value of the time series at time t + 1. Now, when I'm in t + 1, I would ...
0
votes
0answers
21 views

Extracting/Exporting the Data of the Empirical Cumulative Distribution Function in R (ecdf) [migrated]

I use R to calculate the ecdf of some data. I want to use the results in another software. I use R just to do the 'work' but not to produce the final diagram for my thesis. Example Code ...
0
votes
0answers
12 views

Selecting from a bigger control group for 1:1 ratio

What I have is a treatment group consisting of 90 individuals. I have a pool of individuals eligible for my control group, which I want to be matched by age and gender in a 1:1 ratio. Is there any ...
1
vote
0answers
5 views

How to calculate model residuals from MCMCregress [migrated]

I'm doing classwork using Bayesian inference. For this, I'm using the MCMCregress function, from MCMCpack. The problem comes ...
0
votes
0answers
13 views

Determine the threshold value and number of regimes with delayed variable

I am currently working on a threshold model for the exchange rate between UK and US. I have not got background knowledge on this model so I am really stuck on how to determine the Threshold value, ...
0
votes
0answers
13 views

Threshold Models

Im trying to estimate a momentum threshold model for relationship between main stock index, political-risk and economic-risk. The equation I want to evaluate is ...
0
votes
0answers
24 views

List of All Possible Orderings of a Sequence Using R [on hold]

If I have a sequence consisting of three successes and seven failures SSSFFFFFFF, the number of unique orderings of the sequence is choose(10,3) = 120 using R. Is there a function in R that will list ...
0
votes
0answers
21 views

Log-likelihood (and AIC) of robust nlrob model differs from standard nls model

Comparing models generated by nlrob to ones generated by nls, I've noticed that even though the models might be nearly identical, the log-likelihood of the models is sometimes significantly different, ...
0
votes
0answers
16 views

Correlation coefficient for data table

I would like to display correlation coefficients in a table (ideally - with p-value). However, my code produces exactly the same values for each period (so something is obviously wrong). Could you ...
0
votes
0answers
24 views

Understanding ANOVA formula in R and choosing the most appropriate model

I am new to R (and by extension statistics), and am having a tough time in making sense of this repeated measures ANOVA formula, please bear with me. I think I understand what the formula implies, but ...
1
vote
1answer
25 views

Using OLS for Model Selection and Prediction - Heteroscedasticity Issue

I am new to regression and having problem in solving Heteroscedasticity in OLS. Have done lots of homework and test before seeking your advice. Sharing the background and what I have done to solve the ...
0
votes
0answers
9 views

How to calculate prediction intervals in major axis regression using R

Need help in calculation of prediction intervals in major axis regression (MA). I'm using 'lmodel2' package for calculation of the MA, but I don't understand how to calculate prediction intervals ...
0
votes
0answers
27 views

Which Test to Use?

I was wondering if someone could help me regarding the statistical tests I should use. Basically I have the following: 1) I carried out a survey asking teachers and students to rank components in my ...
0
votes
0answers
7 views

How to use Hartemink's discretization algorithm?

From the help documentation of the discretize function of the R package bnlearn: Hartemink's algorithm has been designed to ...
0
votes
0answers
12 views

How to extract the importance of predictors in Adaptive boosting?

I have trained a boosting classifier using ada package in R. Now I want to see the importance of my predictors in constructing ...
0
votes
0answers
7 views

Neighbours list extracted out of polygon regions [migrated]

I've got a SQL database which contains some coded polygon structures. Those can be extracted as follows ...
0
votes
1answer
34 views

Survival Analysis in R with Grouped Data

I'm just getting started with survival analysis and I'm having trouble finding something in R that will do what I'm looking for. Most of the packages use survival ...
2
votes
1answer
39 views

How can I estimate model predicted means (a.k.a. marginal means, lsmeans, or EM means) from a GEE model fitted in R?

I am trying to obtain model-predicted means and CI's for a categorical predictor in a GEE model fitted with the geeglm function (geepack package). The model is fitted with no problem, but where I am ...
1
vote
0answers
27 views

lmmlasso does not work for p>n

I am using the following example from the R manual: ...
0
votes
0answers
15 views

Specifying lag in `dlnm` when passing arguments to `crossbasis`

I am using the dlnm package to build a finite distribute lag linear model. I intend on testing the model-fit based on various lag levels to assess which lag is ...
0
votes
1answer
41 views

Clustering high dimensional data (p > n) in R

I have a situation where we have a number of quantitative features / variables (p) than the number of samples (n). My objective is to classify these samples into groups (may be hierarchical). I can ...
0
votes
1answer
17 views

Leave-one-subject-out cross validation in Caret

Hi Dear Colleagues, I wonder how to correctly setup a leave-one-subject-out cross validation (LOSO) for train() function in caret. Here is my example code: ...
0
votes
0answers
36 views

VIF in GLM model in R

Before running or building a model, ho can we check on the multicollinearity between different covariates in GLM model in R? I know that SAS Proc MIXED procedure gives a column for VIF which is very ...
0
votes
0answers
32 views

Problem when doing pre-whitening before ccf analysis [migrated]

I have following R code which does not work when trying to pre-whiten other series by the model generated for the other series. ...
0
votes
0answers
8 views

boosting with ada package. How do I take the most probable answer from predict?

I trained classifier using ada. Now I executed: predict(adaDol,newdata=cords()) and received response: ...
0
votes
0answers
21 views

Sharing a Legend between two combined ggplots [migrated]

I'm currently trying to present two time series using ggplot2, both with very different scales, using two ggplots. I've combined the two separate ggplots, one on top of the other, using ...
0
votes
0answers
20 views

R: Package 'sphet' on spatial autoregressive models

I'm using the function gstslshet from the package sphet in R, but I'm wondering what the outcome is. Is it a model which can be ...
0
votes
0answers
19 views

Can we easily avoid the “maximum supported lag is 350 error” when using the ARIMA function in R? [migrated]

I am currently fitting a SARIMAX model to big data sets. Information is retrieved every 10 minutes, so I have a vector of size 52560 for a year of data. Considering it is representing electricity load ...
1
vote
1answer
25 views

Creating a cluster analysis on multiple variables

I am working on creating a cluster analysis for some very basic data in r for Windows [Version 6.1.76]. The groups themselves are countries and then I have 2 column with continuous numerical ...
1
vote
0answers
12 views

R Sales Modeling with Non-Replenishing Inventory

I'm working on modeling sales for tickets for a specific event over time. The issue that I'm having is that the inventory does not replenish, so I can't have my model predicting over what I actually ...