2015年7月28日 星期二

7.28 Learning handling dataframe by sqldf in R

http://anythingbutrbitrary.blogspot.com/2012/08/manipulating-data-frames-using-sqldf.html
  • A useful blog for learning using sqldf to conduct query in R.

One more tip:
> s01 <- sqldf("select * from data where [group.code] = 'a'")
# The bracket avoids misunderstanding of dot in sqldf. The dot has another meaning
# in SQL (e.g., separating table name from column name) and is replaced by an
# underscore before sending the data to SQLite.
# URL: http://stackoverflow.com/questions/19019883/how-to-handle-column-names-not-supported-by-sqldf-in-r

2015年7月27日 星期一

7.27 R coding - Don't forget the cached input <<-

When using "<<-" instead of "<-", the variable is cached and can be used outside the function. This will be useful especially when one wants to execute a bunch of function within a single call.

2015年7月24日 星期五

7.24 Demean Categorical Variable, Seriously?

What if the categorical variables containing multiple values which are completely irrelevant?

2015年7月23日 星期四

7.23 But we need to figure out how to use GLM do to that first.

As the title indicated. This is taking forever. GLM is so slow.

And there are two websites which is ridiculous. A few complaints here just releasing the stress.
For categorical covariates (e.g. gender), treat in exactly the same way as continuous covariates - that is, use two indicator values (e.g. 0 and 1) and then demean these values before entering them into the EV. 

To adjust for multiple covariates, simply add more EVs to the model, one for each additionally covariate and mean center each covariate.

7.23 Using gedit to create specific design.con and design.mat

This link from UTexas is very helpful:
http://wikis.la.utexas.edu/imagelab/book/statistical-analysis-fa-values

  • The design.mat files looks like this:
/NumWaves 2
/NumPoints 4
/PPheights 1 1
/Matrix
0 1
1 0
1 0
0 1
  • The design.con file will look like this:
/NumWaves 2
/NumContrasts 2
/PPheights 1 1
/Matrix
1 -1
-1 1

Just open gedit on ssh shell and modify these parameters when later on need to add covariate into the statistical analysis.

Another way is using R to do that, which requires additional step (import the data, re-combine the rows with attention paying to the datatype, then export it (which I still not figure out)). Anyway, gedit is super fast.
 

2015年7月21日 星期二

7.21 Add pagebreak in Rmd for LaTeX conversion

Very technical detail but useful to learn. Thanks for the midterm from CMU.

http://www.stat.cmu.edu/~nmv/setup/stat202/tests/midterm-student-version.Rmd

Simply adding a line "\pagebreak" will introduce a page break for later on converting to a LaTeX pdf file. Remember to leave a line with the latter contents.

And just figured out that I can make system call in R (system()). This is so cool, lazy boy.

7.21 VA Research - Add Covariate in TBSS

In the coming future, it is very likely that I will be referencing this website for performing statistics on my master thesis, so I am going to mark it down here.

http://white.stanford.edu/newlm/index.php/MrVista_TBSS