search for: ind1year1999

Displaying 1 result from an estimated 1 matches for "ind1year1999".

2010 Aug 01
3
remove extreme values or winsorize – loop - dataframe
...1<-rnorm(10000) data<-data.frame(firm, industry,year,X1) data The way I?m doing this is very hard. I split my sample by industry and year, for each industry and year I calculate the 10% and 90% quantiles, then I create a X2 variable like this: industry1<-subset(data,data$industry==1) ind1year1999<-subset(industry1,industry1$year==1999) q1<-quantile(ind1year1999$X1,probs=0.1,na.rm=TRUE) q99<-quantile(ind1year1999$X1,probs=0.90,na.rm=TRUE) ind1year1999winsorized<-transform(ind1year1999,X2=ifelse(X1<q1,q1,ifelse(X1>q99,q99,X1))) ind1year2000<-subset(industry1,industry1$ye...