# loops

1. ### A little help with looping..

Below is a similar to a data set I am working with... I am struggling to write a loop that would go through the data and add a new column 'Rank' based on the other two columns.. So for example if the 'Color' = 'red' and measure between 0-2 then it would have a rank of 1 'Color - 'red'...
2. ### Automating VIF calculation on mutliple linear models

I came up with this code to calculate VIF for variables for each model I am evaluating displayvif<-function(x){ for (i in 1:length(x)) vif(x[[i]]) } where x is models<-lapply(d1,function(data){lm(reformulate(termlabels=".",response=names(data)),data)}) and where d1...
3. ### SPSS Macro or Looping Function

Hi All, I am hoping to get some advice about a possible macro or looping expression that may save me some time here. I have 50 columns of data across 90,000 rows that stipulate product departments that each individual viewed during a specific web visit. Each column could take one of 72...
4. ### loop regression based on variable

Dear statisticians, I'm trying to loop a regression on a panel data set. I have the following variables: iden1: cross sectional variable (non-sequential numerical) year: time series variable SIC2: industry variable (non-sequential numerical) What I would like to do is run a regression...
5. ### Converting syntax between python and STATA

Dear colleagues, Im converting a code written in PYTHON to STATA and I'm stuck at the point when have to apply the iterative procedure. Cannot find the way to write the loop so that it includes the initial value and generates an estimate for lat. Has any of you got any experience with that...
6. ### Loops (problem)

Hi, I am new to R and having problems with understanding loops in R. basically what i want is the following say i have a variable y with 100 observations I want y1 = first 20 observations y2 = second 20 obs y3 = third 20 obs and so on until y5 i know i can do that with y1 <- c(y[1:20])...
7. ### Saving regression results into a variable

I have time-series data for many countries on exchange rate, consumer price index and interest rate. Now I need for further analysis to save regression results in variables. What I do: For each country regress changes in exchange rate to changes in CPI and real interest rate bysort...
8. ### looping a procedure that utilizes an integration of a function

Hi, all. I've written a function that returns the survival function for a Gompertz mortality model. I've specified the two model parameters. With a calculation that includes a simple integration, I can calculate the life expectancy at any age. Is there a way I can use a loop with the...
9. ### Observations with probability in R

Hello, please assist me in answering the following question involving R code and statistics. Loop through CoinTosses<-matrix(nrow=5000,ncol=20) to simulate for each column, 50 coin tosses where a toss has a probability of heads, from 0.05 to 1 probability in each column respectively. Coin...