tag:blogger.com,1999:blog-23904127858041667402024-03-13T19:47:23.636+08:00wnarifinWan Nor Arifinhttp://www.blogger.com/profile/03638512989693683591noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-2390412785804166740.post-47924452905423049602015-08-04T16:03:00.000+08:002015-08-05T09:50:16.301+08:00Recoding multiple variables in a data frameI had a dataset with a number of variables on knowledge. The response options for the variables were coded as 1, 2 and 3. I wanted to recode them to 1 or 0 depending on whether the answers were right or wrong. However, it would be inefficient to recode every single variable in R, although it could be just a matter of copy/paste/edit task. I was thinking of looping through the relevant columns, assigning new values in each iteration, but looping would make the code difficult to digest and ugly to look at. I simply could not stand ugly codes<br>
<br>
I had gone through a number of blogs and websites to find the most elegant way to solve this problem, but to no avail. The best solution I could find was at <a href="http://rprogramming.net/recode-data-in-r/">http://rprogramming.net/recode-data-in-r/</a>, but I didn't like apply+function as it would be an overkill for medical personnel and researchers (of whom I deal with on daily basis) without programming basics. I need an extremely simple solution so that people won't shy away from R. I could not get the problem off my mind until I finally found a simple solution on my own :-) Here I share the codes:<br>
<pre class="code">library("car")
# create a data frame
data = read.table(header=T, text="
Q1 Q2 Q3 Q4 Q5
2 2 2 2 1
2 1 2 1 2
2 2 2 2 2
3 3 3 1 1
2 2 2 2 1
")
# Let say for Q1, Q3 and Q5, the correct option is 3, thus recoded as 1, the rest as 0
data.recode = data
mat = as.matrix(data.recode[c(1,3,5)])
mat = recode(mat, "3=1; else=0")
data.recode[c(1,3,5)] = as.data.frame(mat)
# Let say for Q2 and Q4, the correct option is 2, thus recoded as 1, the rest as 0
mat = as.matrix(data.recode[c(2,4)])
mat = recode(mat, "2=1; else=0")
data.recode[c(2,4)] = as.data.frame(mat)
# Compare the original data with recoded ones
data
data.recode
</pre>
Outputs:
<pre class="output">> data
Q1 Q2 Q3 Q4 Q5
1 2 2 2 2 1
2 2 1 2 1 2
3 2 2 2 2 2
4 3 3 3 1 1
5 2 2 2 2 1
> data.recode
Q1 Q2 Q3 Q4 Q5
1 0 1 0 1 0
2 0 0 0 0 0
3 0 1 0 1 0
4 1 0 1 0 0
5 0 1 0 1 0
</pre>Wan Nor Arifinhttp://www.blogger.com/profile/03638512989693683591noreply@blogger.com0tag:blogger.com,1999:blog-2390412785804166740.post-34552264341665286882015-02-07T09:53:00.003+08:002015-08-05T09:50:27.554+08:00Hows many cows? in ROur cows problem as posted before <a href="http://wnarifin.blogspot.com/2014/12/how-many-cows-are-required-per-farm-so.html">here</a> can also be solved in R (obviously). Compare our results with the <a href="http://wnarifin.blogspot.com/2015/02/how-many-cows-simulation-in-r.html">simulation results</a>.<br />
<pre class="r"><code>################################
# We are looking at 0.7 cutoff
# point for sensitivity
################################
# Using R
# Iterate over values
###############################
n = numeric(1)
n.low = 4 # lower limit of n
n.high = 7 # upper limit of n
pr = numeric(0)
p = 0.25 # prevalence of dss
n_ = numeric(0)
pr_ = numeric(0)
for(i in n.low:n.high) {
n = i
print(n)
pr = 1 - pbinom(0, n, p)
print(pr)
n_[i] = n
pr_[i] = pr
}</code></pre>
The results are as follows:<br />
<pre><code>## [1] 4
## [1] 0.6835937
## [1] 5
## [1] 0.7626953
## [1] 6
## [1] 0.8220215
## [1] 7
## [1] 0.8665161</code></pre>
<pre class="r"><code># sample size vs sensitivity
cbind(n=n_[n.low:n.high], Sensitivity=pr_[n.low:n.high])</code></pre>
<pre><code>## n Sensitivity
## [1,] 4 0.6835937
## [2,] 5 0.7626953
## [3,] 6 0.8220215
## [4,] 7 0.8665161</code></pre>
<pre class="r"><code># only 0.7 & above
cbind(n=n_[n.low:n.high], Sensitivity=pr_[n.low:n.high])[pr_[n.low:n.high] > 0.7, ]</code></pre>
<pre><code>## n Sensitivity
## [1,] 5 0.7626953
## [2,] 6 0.8220215
## [3,] 7 0.8665161</code></pre>
Wan Nor Arifinhttp://www.blogger.com/profile/03638512989693683591noreply@blogger.com0tag:blogger.com,1999:blog-2390412785804166740.post-30953930803770262682015-02-07T09:47:00.001+08:002015-08-05T09:50:39.291+08:00How many cows? Simulation in RIn continuation of our cows problem as posted before <a href="http://wnarifin.blogspot.com/2014/12/how-many-cows-are-required-per-farm-so.html">here</a>, we can also solved the problem by simulation approach. I would like to thank <a href="http://www.mikemeredith.net/">Mike Meredith</a> for his contribution and guidance in producing the codes below. The code can be obtained <a href="https://dl.dropboxusercontent.com/u/89006826/pancake/r-blog/cows.R">here</a>.<br />
<pre class="r"><code>################################
# Try with different sized herds
################################
# We are looking at 0.7 cutoff
# point for sensitivity
################################
# Simulation approach
###############################
B = 10000
p = 0.25
n = numeric(1) # sample size
nCow = numeric(10) # number of cows per farm per iteration
nCow_ = numeric(10) # nCow, for tabulation with cbind
sensitivity = numeric(0)
infected = numeric(B) # real no of infected cows per farm
detected = numeric(B) # no of infected cows in sample of size n
n.low = 4 # lower limit of sample size
n.high = 7 # upper limit of sample size
sen_ = numeric(0) # mean sensitivity for all sizes of farm
n_ = numeric(0) # sample size
cutpt = 0.7 # Acceptable cutoff point
for(x in n.low:n.high) {
n = x
print("+++++++")
print(n)
for(c in 1:50) {
nCow = 10*c
for(i in 1:B) {
cows = rbinom(nCow, 1, p)
infected[i] = sum(cows)
s = sample(cows, n)
detected[i] = sum(s)
}
nCow_[c] = nCow
detected.if.present = detected[infected > 0]
sensitivity[c] = mean(detected.if.present > 0)
}
temp_s = mean(sensitivity)
temp_c = cbind(sensitivity=sensitivity, ncow_=nCow_)
print(temp_c)
print(n)
print(temp_s)
sen_[x] = temp_s
n_[x] = n
}</code></pre>
The results are as follows:<br />
<pre><code>## [1] "+++++++"
## [1] 4
## sensitivity ncow_
## [1,] 0.7217031 10
## [2,] 0.6771314 20
## [3,] 0.6893379 30
## [4,] 0.6805000 40
## [5,] 0.6850000 50
## [6,] 0.6796000 60
## [7,] 0.6784000 70
## [8,] 0.6769000 80
## [9,] 0.6878000 90
## [10,] 0.6863000 100
## [11,] 0.6904000 110
## [12,] 0.6852000 120
## [13,] 0.6882000 130
## [14,] 0.6873000 140
## [15,] 0.6846000 150
## [16,] 0.6837000 160
## [17,] 0.6842000 170
## [18,] 0.6875000 180
## [19,] 0.6872000 190
## [20,] 0.6856000 200
## [21,] 0.6859000 210
## [22,] 0.6796000 220
## [23,] 0.6905000 230
## [24,] 0.6801000 240
## [25,] 0.6783000 250
## [26,] 0.6769000 260
## [27,] 0.6793000 270
## [28,] 0.6892000 280
## [29,] 0.6802000 290
## [30,] 0.6831000 300
## [31,] 0.6772000 310
## [32,] 0.6891000 320
## [33,] 0.6845000 330
## [34,] 0.6778000 340
## [35,] 0.6789000 350
## [36,] 0.6863000 360
## [37,] 0.6862000 370
## [38,] 0.6796000 380
## [39,] 0.6806000 390
## [40,] 0.6878000 400
## [41,] 0.6836000 410
## [42,] 0.6827000 420
## [43,] 0.6761000 430
## [44,] 0.6823000 440
## [45,] 0.6847000 450
## [46,] 0.6860000 460
## [47,] 0.6818000 470
## [48,] 0.6789000 480
## [49,] 0.6813000 490
## [50,] 0.6776000 500
## [1] 4
## [1] 0.6838534
## [1] "+++++++"
## [1] 5
## sensitivity ncow_
## [1,] 0.8058705 10
## [2,] 0.7680433 20
## [3,] 0.7726545 30
## [4,] 0.7627000 40
## [5,] 0.7625000 50
## [6,] 0.7658000 60
## [7,] 0.7642000 70
## [8,] 0.7585000 80
## [9,] 0.7631000 90
## [10,] 0.7666000 100
## [11,] 0.7630000 110
## [12,] 0.7558000 120
## [13,] 0.7634000 130
## [14,] 0.7595000 140
## [15,] 0.7623000 150
## [16,] 0.7590000 160
## [17,] 0.7623000 170
## [18,] 0.7619000 180
## [19,] 0.7614000 190
## [20,] 0.7583000 200
## [21,] 0.7568000 210
## [22,] 0.7626000 220
## [23,] 0.7618000 230
## [24,] 0.7653000 240
## [25,] 0.7633000 250
## [26,] 0.7595000 260
## [27,] 0.7697000 270
## [28,] 0.7675000 280
## [29,] 0.7623000 290
## [30,] 0.7653000 300
## [31,] 0.7592000 310
## [32,] 0.7574000 320
## [33,] 0.7668000 330
## [34,] 0.7678000 340
## [35,] 0.7595000 350
## [36,] 0.7654000 360
## [37,] 0.7666000 370
## [38,] 0.7665000 380
## [39,] 0.7648000 390
## [40,] 0.7551000 400
## [41,] 0.7713000 410
## [42,] 0.7730000 420
## [43,] 0.7653000 430
## [44,] 0.7577000 440
## [45,] 0.7627000 450
## [46,] 0.7577000 460
## [47,] 0.7735000 470
## [48,] 0.7675000 480
## [49,] 0.7593000 490
## [50,] 0.7601000 500
## [1] 5
## [1] 0.7641634
## [1] "+++++++"
## [1] 6
## sensitivity ncow_
## [1,] 0.8661619 10
## [2,] 0.8254589 20
## [3,] 0.8242000 30
## [4,] 0.8219822 40
## [5,] 0.8192000 50
## [6,] 0.8272000 60
## [7,] 0.8175000 70
## [8,] 0.8182000 80
## [9,] 0.8251000 90
## [10,] 0.8166000 100
## [11,] 0.8256000 110
## [12,] 0.8178000 120
## [13,] 0.8246000 130
## [14,] 0.8280000 140
## [15,] 0.8172000 150
## [16,] 0.8160000 160
## [17,] 0.8235000 170
## [18,] 0.8167000 180
## [19,] 0.8270000 190
## [20,] 0.8242000 200
## [21,] 0.8208000 210
## [22,] 0.8242000 220
## [23,] 0.8173000 230
## [24,] 0.8203000 240
## [25,] 0.8234000 250
## [26,] 0.8339000 260
## [27,] 0.8180000 270
## [28,] 0.8237000 280
## [29,] 0.8179000 290
## [30,] 0.8208000 300
## [31,] 0.8206000 310
## [32,] 0.8231000 320
## [33,] 0.8174000 330
## [34,] 0.8227000 340
## [35,] 0.8188000 350
## [36,] 0.8241000 360
## [37,] 0.8225000 370
## [38,] 0.8271000 380
## [39,] 0.8225000 390
## [40,] 0.8243000 400
## [41,] 0.8232000 410
## [42,] 0.8219000 420
## [43,] 0.8199000 430
## [44,] 0.8138000 440
## [45,] 0.8287000 450
## [46,] 0.8236000 460
## [47,] 0.8193000 470
## [48,] 0.8209000 480
## [49,] 0.8304000 490
## [50,] 0.8227000 500
## [1] 6
## [1] 0.8230001
## [1] "+++++++"
## [1] 7
## sensitivity ncow_
## [1,] 0.9164819 10
## [2,] 0.8687719 20
## [3,] 0.8698870 30
## [4,] 0.8692000 40
## [5,] 0.8674000 50
## [6,] 0.8717000 60
## [7,] 0.8579000 70
## [8,] 0.8659000 80
## [9,] 0.8610000 90
## [10,] 0.8633000 100
## [11,] 0.8686000 110
## [12,] 0.8620000 120
## [13,] 0.8652000 130
## [14,] 0.8633000 140
## [15,] 0.8657000 150
## [16,] 0.8637000 160
## [17,] 0.8642000 170
## [18,] 0.8618000 180
## [19,] 0.8628000 190
## [20,] 0.8692000 200
## [21,] 0.8644000 210
## [22,] 0.8641000 220
## [23,] 0.8671000 230
## [24,] 0.8625000 240
## [25,] 0.8625000 250
## [26,] 0.8696000 260
## [27,] 0.8689000 270
## [28,] 0.8565000 280
## [29,] 0.8703000 290
## [30,] 0.8606000 300
## [31,] 0.8695000 310
## [32,] 0.8664000 320
## [33,] 0.8696000 330
## [34,] 0.8642000 340
## [35,] 0.8723000 350
## [36,] 0.8670000 360
## [37,] 0.8700000 370
## [38,] 0.8662000 380
## [39,] 0.8667000 390
## [40,] 0.8642000 400
## [41,] 0.8627000 410
## [42,] 0.8686000 420
## [43,] 0.8669000 430
## [44,] 0.8715000 440
## [45,] 0.8695000 450
## [46,] 0.8706000 460
## [47,] 0.8658000 470
## [48,] 0.8619000 480
## [49,] 0.8660000 490
## [50,] 0.8668000 500
## [1] 7
## [1] 0.8670188</code></pre>
<pre class="r"><code># sample size vs sensitivity
cbind(n=n_[n.low:n.high], Sensitivity=sen_[n.low:n.high])</code></pre>
<pre><code>## n Sensitivity
## [1,] 4 0.6838534
## [2,] 5 0.7641634
## [3,] 6 0.8230001
## [4,] 7 0.8670188</code></pre>
<pre class="r"><code># only > cutoff point
cbind(n=n_[n.low:n.high], Sensitivity=sen_[n.low:n.high])[sen_[n.low:n.high] > cutpt, ]</code></pre>
<pre><code>## n Sensitivity
## [1,] 5 0.7641634
## [2,] 6 0.8230001
## [3,] 7 0.8670188</code></pre>
Wan Nor Arifinhttp://www.blogger.com/profile/03638512989693683591noreply@blogger.com0tag:blogger.com,1999:blog-2390412785804166740.post-26510879884451298062014-12-08T00:21:00.000+08:002014-12-08T00:26:41.554+08:00Setting up hot corner + expose effect in XFCE on Linux MintSetting up hot corner + expose effect in XFCE was already discussed somewhere else here <a href="http://forum.xfce.org/viewtopic.php?id=8105">http://forum.xfce.org/viewtopic.php?id=8105</a>, so I could not claim <i><b>I'm first</b></i> in that respect.<br />
<br />
However I could not find step-by-step solution for Linux Mint, thus I'm sharing the steps here.<br />
<br />
1. Install <span style="font-family: Courier New, Courier, monospace;">brightside</span> (via <b>Synatic Package Manager</b> or <span style="font-family: Courier New, Courier, monospace;">apt-get</span>).<br />
<br />
2. Install <span style="font-family: Courier New, Courier, monospace;">skippy-xd</span> (<a href="https://code.google.com/p/skippy-xd/">https://code.google.com/p/skippy-xd/</a>). You'll need to compile from source for this one.<br />
<br />
- Download the source (<a href="https://github.com/richardgv/skippy-xd">https://github.com/richardgv/skippy-xd</a>)<br />
- Install required development packages (<a href="https://code.google.com/p/skippy-xd/wiki/Installation">https://code.google.com/p/skippy-xd/wiki/Installation</a>)<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">sudo apt-get install libimlib2-dev libfontconfig1-dev libfreetype6-dev libx11-dev libxext-dev libxft-dev libxrender-dev zlib1g-dev libxinerama-dev libxcomposite-dev libxdamage-dev libxfixes-dev libxmu-dev</span><br />
<br />
- Extract the source (unzip).<br />
- <span style="font-family: Courier New, Courier, monospace;">cd</span> into the source folder, then<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">make</span><br />
<br />
followed by<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">sudo make install</span><br />
<br />
which would install <span style="font-family: Courier New, Courier, monospace;">skippy-xd</span> into <span style="font-family: Courier New, Courier, monospace;">/usr/bin</span><br />
<br />
3. Run <span style="font-family: Courier New, Courier, monospace;">brightside-properties</span>, and set <b>Custom action...</b> > <b>On entering region</b> to <span style="font-family: Courier New, Courier, monospace;">skippy-xd</span>.<br />
<br />
4. To wrap things up, add <span style="font-family: Courier New, Courier, monospace;">brightside</span> to your list of <b>Application Autostart</b>.Wan Nor Arifinhttp://www.blogger.com/profile/03638512989693683591noreply@blogger.com1tag:blogger.com,1999:blog-2390412785804166740.post-56209925748745395292014-12-07T23:35:00.001+08:002014-12-08T00:27:14.017+08:00How many cows are required per farm so as the probability of getting at least one diseased cow is 70%?Today I stumbled upon a problem during a student presentation.<br />
<br />
How many cows are required per farm so as the probability of getting at least one diseased cow is 70% (acceptable level to us, using area under ROC cutoff point), given that the disease prevalence is 25%?<br />
<br />
My solution for this problem is by using binomial distribution. The following is the formula for the distribution,<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-T01D8XciuNs/VIRrFUm-2MI/AAAAAAAABrE/aWVTdWmlLME/s1600/binomial.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://2.bp.blogspot.com/-T01D8XciuNs/VIRrFUm-2MI/AAAAAAAABrE/aWVTdWmlLME/s1600/binomial.gif" /></a></div>
In our context,<br />
<br />
<span style="font-family: inherit;"><i>x</i>, number of success</span><br />
<span style="font-family: inherit;"><i>n</i>, sample size</span><br />
<span style="font-family: inherit;"><i>p</i>, prevalence</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: inherit;">and to solve our problem</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;"><i>p</i>(1 or more) = 1 - <i>p</i>(0)</span><br />
<span style="font-family: inherit;"><br /></span>
Using spreadsheet, we can find the value of <i><span style="font-family: inherit;">n</span></i> iteratively (I prefer LibreOffice Calc). Just key in the following function (or just put up the formula above)<br />
<br />
=1 - BINOMDIST(n, x, p, 1)<br />
<br />
thus in our context<br />
<br />
=1 - BINOMDIST(n, 0, 0.25, 1)<br />
<br />
after playing around with <i>n</i>, I found<br />
<br />
for <i>n</i> = 4, <i>p</i>(1 or more) = 1 - 0.316<i> = </i>0.684<br />
<br />
for <span style="font-family: inherit;"><i>n</i></span> = 5, <i>p</i>(1 or more) = 1 - 0.237<i> = </i>0.763<br />
<br />
I'd go for 5 cows...Wan Nor Arifinhttp://www.blogger.com/profile/03638512989693683591noreply@blogger.com0tag:blogger.com,1999:blog-2390412785804166740.post-55149553524632419902014-12-04T14:52:00.000+08:002014-12-04T14:58:53.273+08:00Installing STATA 11 on Linux MintI could not manage to run the provided <span style="font-family: Courier New, Courier, monospace;">install </span>script to install STATA 11/SE on my Linux Mint LMDE 201403 system, so I went through the script itself and did everything manually.<br />
<br />
The steps were as follows:<br />
<br />
1. Copy <span style="font-family: Courier New, Courier, monospace;">unix/linux.64</span> contents to local disk, let say to <span style="font-family: Courier New, Courier, monospace;">~/Downloads/stata11</span>. The files are<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">ls</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">ado.taz base.taz bins.taz install setrwxp utilities.taz</span><br />
<br />
2. Create installation folder <span style="font-family: Courier New, Courier, monospace;">/usr/local/stata11</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">sudo /usr/local/stata11</span><br />
<br />
3. Create symlink to the folder<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">sudo ln -s /usr/local/stata11 /usr/local/stata</span><br />
<br />
4. Copy all files to <span style="font-family: Courier New, Courier, monospace;">/usr/local/stata11</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">sudo cp ~/Downloads/stata11/* /usr/local/stata11</span><br />
<br />
5. Uncompress all <span style="font-family: Courier New, Courier, monospace;">.taz</span> files<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">cd /usr/local/stata11</span><br />
<span style="font-family: Courier New, Courier, monospace;">sudo uncompress *.taz</span><br />
<br />
would result in:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">ls</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">ado.tar base.tar bins.tar install setrwxp utilities.tar</span><br />
<br />
6. Untar all <span style="font-family: Courier New, Courier, monospace;">.tar</span> files<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">tar -xof ado.tar</span><br />
<span style="font-family: Courier New, Courier, monospace;">tar -xof base.tar</span><br />
<span style="font-family: Courier New, Courier, monospace;">tar -xof bins.tar</span><br />
<span style="font-family: Courier New, Courier, monospace;">tar -xof utilities.tar</span><br />
<br />
would result in:<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">ls</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
<span style="font-family: Courier New, Courier, monospace;">ado<span class="Apple-tab-span" style="white-space: pre;"> </span> stata<span class="Apple-tab-span" style="white-space: pre;"> </span> stata.lic stata_pdf<span class="Apple-tab-span" style="white-space: pre;"> </span>utilities xstata-se</span><br />
<span style="font-family: Courier New, Courier, monospace;">auto.dta stata11.png stata-mp stata-se<span class="Apple-tab-span" style="white-space: pre;"> </span>xstata</span><br />
<span style="font-family: Courier New, Courier, monospace;">isstata.110 stata_br<span class="Apple-tab-span" style="white-space: pre;"> </span> stata.msg stinit<span class="Apple-tab-span" style="white-space: pre;"> </span>xstata-mp</span><br />
<br />
in addition to all our installation files listed above.<br />
<br />
7. Remove all <span style="font-family: Courier New, Courier, monospace;">.tar</span> files<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">rm *.tar</span><br />
<br />
8. Set permission using <span style="font-family: Courier New, Courier, monospace;">setrwxp</span> script<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">sudo ./setrwxp</span><br />
<br />
9. Once done, just remove <span style="font-family: Courier New, Courier, monospace;">install</span> and <span style="font-family: Courier New, Courier, monospace;">setrwxp</span> from the folder<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">sudo rm install setrwxp</span><br />
<br />
10. Start license authorization<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">sudo ./stinit</span><br />
<br />
11. Once done with license authorization, try running STATA 11/SE GUI version.<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;">./xstata-se</span><br />
<br />
You will get a number of errors. The following are the errors with solution:<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;">./xstata-se: error while loading shared libraries: libtiff.so.3: cannot open shared object file: No such file or directory</span><br />
<br />
Check whether you have <span style="font-family: Courier New, Courier, monospace;">libtiff4</span>. If not install using Synaptic Package Manager or <span style="font-family: Courier New, Courier, monospace;">apt-get</span>. Then make symlink to <span style="font-family: Courier New, Courier, monospace;">libtiff.so.4</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">sudo ln -s x86_64-linux-gnu/libtiff.so.4 libtiff.so.3</span><br />
<br />
Followed by<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">./xstata-se: error while loading shared libraries: libgtksourceview-1.0.so.0: cannot open shared object file: No such file or directory</span><br />
<br />
Install <span style="font-family: Courier New, Courier, monospace;">libgtksourceview2.0-0</span> using Synaptic Package Manager or <span style="font-family: Courier New, Courier, monospace;">apt-get</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">sudo ln -s libgtksourceview-2.0.so.0 libgtksourceview-1.0.so.0</span><br />
<br />
12. Run STATA again<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">./xstata-se</span><br />
<br />
13. To be able to run directly from Terminal without going to <span style="font-family: Courier New, Courier, monospace;">/usr/local/stata11</span> folder, set your path in <span style="font-family: Courier New, Courier, monospace;">~/.profile</span><br />
<br />
<span style="font-family: Courier New, Courier, monospace;">gedit ~/.profile</span><br />
<br />
and edit this line<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">PATH="$HOME/bin:$PATH"</span><br />
<br />
to<br />
<br />
<span style="font-family: Courier New, Courier, monospace;">PATH="$HOME/bin:$PATH:/usr/local/stata"</span><br />
<br />
Log out and log in again to apply the change.Wan Nor Arifinhttp://www.blogger.com/profile/03638512989693683591noreply@blogger.com1tag:blogger.com,1999:blog-2390412785804166740.post-27689875192242260842014-10-08T23:45:00.001+08:002014-10-08T23:57:05.504+08:00Convert variable name list to comma separated variable namesThis trick is quite useful for SPSS. Let say I have 50 variables that I want to sum up the values by using SUM(var1,var2, ...) in <b>Transform > Compute variable...</b>, converting the list:<br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">var1<br />var2<br />...<br />var50</span></blockquote>
to<br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">var1,var2,...,var50</span></blockquote>
then<br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">SUM(var1,var2,...var50)</span></blockquote>
is quite tedious.<br />
<br />
I found this nice command line from <a href="http://www.shellhacks.com/">http://www.shellhacks.com/</a> (in Linux, of course). Save your list in a file, say <span style="font-family: Courier New, Courier, monospace;">temp_file</span>, then<br />
<blockquote class="tr_bq">
<span style="font-family: Courier New, Courier, monospace;">echo $(awk 'NR > 1{print line", "}{line=$0;}END{print $0" "}' temp_file) > new_file</span></blockquote>
Your comma separated variable names are ready in <span style="font-family: Courier New, Courier, monospace;">new_file</span>. Thanks, penguin.Wan Nor Arifinhttp://www.blogger.com/profile/03638512989693683591noreply@blogger.com0tag:blogger.com,1999:blog-2390412785804166740.post-84629278262073354452014-10-08T16:05:00.000+08:002014-10-08T23:53:38.757+08:00Installing SPSS 22 on Linux Mint<ol>
<li>My setup: Linux Mint LMDE 201403, wine-1.4.1, PlayOnLinux 4.2.1</li>
<li>Install SPSS as usual from installation folder ("setup.exe") using Playonlinux. 32 bit installation.</li>
<li>After installation is finished, make shortcuts for "stats.exe" (SPSS) and "law.exe" (Licence authorization wizard).</li>
<li>Download "echoid.dat" from IBM website (http://www-01.ibm.com/support/docview.wss?uid=swg21613684). Copy to installation folder in Playonlinux virtual drive.</li>
<li>Run Licence authorization wizard from Playonlinux. Then run SPSS.</li>
<li>After running analysis, table in output cannot be displayed.</li>
<li>Go to Edit > Options > Pivot Tables.</li>
<li>"Render Legacy Tables".</li>
</ol>
Wan Nor Arifinhttp://www.blogger.com/profile/03638512989693683591noreply@blogger.com2