Thursday, July 11, 2013

Stressing out

Occasionally, I try and delve into research areas just out of fun and interest. A long time ago, I was working on the impact of stress on the physiological structure of populations, and the impact on infectious disease, inspired by Andy Dobson, and a good reading of Bob Sapolsky's excellent book, Why Zebras Don't Get Ulcers. I didn't get time to really do the subject justice during my short postdoc, but I've maintained an interest in the area. Last year, I tried to put in a grant for a call on Secondary Data Analysis from the U.K. Economic and Social Research Council. Alas, the grant was rejected (but with some great reviews - see below), and thanks to the ever-more austere funding environment, I can't send the proposal back to the ESRC, or even to another funding body in the U.K.. However, I hate wasting time, so on the offchance that someone is interested, here is the grant in its entirety. Apologies for any OpenOffice-to-HTML messiness.

A secondary analysis of stressors, stress, and stress-related outcomes in the United Kingdom

Introduction

Chronic psychosocial stress has been linked to poor mental health, such as depression, chronic disease, including myocardial infarction [1], cancer [2], and diabetes, and infectious disease outcomes [3], particularly upper respiratory infections [4] [5]. As chronic stressors are linked to suppression of both cellular and humoral immunity [6], these associations between stress and health are likely to be causal in nature. Recently, Cohen et al. [7] proposed a model in which chronic stress results in glucocorticoid receptor resistance (GCR) that, in turn, results in failure to down-regulate inflammatory responses. GCR was associated with stress, and those with GCR were more susceptible to developing a cold following challenge with rhinovirus. Such observations are consistent with the concept of allostatic load, developed by McEwen and Stellar [8], which is defined as the physiological consequences of chronic exposure to fluctuating or heightened neural or neuroendocrine response that results from repeated or chronic stress. In practice, allostatic load has been measured in terms of a number of physiological variables, including systolic and diastolic blood pressure, waist:hip ratio, serum HDL and total cholesterol, glycosylated haemoglobin, DHEA-S, overnight urinary cortisol, noradrenalin, and adrenalin excretion [9]. Conditions that may lead to allostatic load include repeated frequency of stress responses to multiple novel stressors; failure to habituate to repeated stressors of the same kind; failure to turn off each stress response in a timely manner due to delayed shut down; and an inadequate response that leads to compensatory hyperactivity of other mediators.

Stress is also a widespread problem. Stress has consistently been one of the most commonly reported types of work-related illness in the Self-reported Work-related Illness (SWI) questionnaire module included annually in the national Labour Force Survey (LFS) conducted by the U.K. Health and Safety Executive [10] , especially in health and social work, education and public administration. Although the LFS has shown a decrease in stress-related absences during the current recession, a recent British Academy Report [11] highlighted that work-related stress has increased over the same time period, possibly due to pressure of attending, and fears over job loss.

>

In contrast to stress in the workplace, the problem of chronic stress and its sequelae in the general population in the U.K. is not well characterised. In the United States, there has been an annual survey by the American Psychological Association since 2007 ('Stress in America'), which has revealed that psychosocial stress is highly prevalent, and increasing over time [12]; there is no similar survey in the U.K.. Similarly, in the 59 studies that employed allostatic load reviewed in [13] , not one employed a sample from the U.K.. This is not to say that there is a lack of interest in this area, as reflected by the commissioning of the Foresight Mental Capital and Wellbeing Project [14]; however, this Foresight project, while considering mental capital, which includes resilience to mental stress, also focused on workplace stress, and only mentions in passing broader issues such as maternal stress (in relation to diet, etc.) and stress amongst children in poor-quality housing. While the Office of National Statistics has recently launched a 'Measuring Societal Well-Being' project [15], the measures are still being developed. Current questions include 'Overall, how satisfied are you with your life nowadays?'; 'Overall, to what extent do you feel the things you do in your life are worthwhile?'; 'Overall, how happy did you feel yesterday?'; and 'Overall, how anxious did you feel yesterday?'. These questions do not directly address stress, nor the potential underlying factors of poor subjective well-being. According to the Organisation for Economic Co-operation and Development (OECD), the United Kingdom ranks well behind many other nations in terms of well-being, ranking 15th (out of 40) in terms of life satisfaction [16] .

We hypothesise that the problem of chronic stress in the U.K. general population is at least as severe as it is in the U.S.. The overarching aim of this study is to perform a secondary data analysis to develop operational definitions of stressors, stress, stress-related outcomes, coping, and allostatic load, to estimate the prevalence of stress and its impact in the U.K. general population, and the dynamics of these measures over time and the life-course. This research promises to fill in a huge gap in our understanding of the importance of stress in the U.K..


Research Questions


  1. To develop operational definitions of stressors, stress, stress-related outcomes (SROs), coping, and allostatic load (AL) that can be applied to retrospective datasets from the U.K.

  2. To investigate the possible causal associations between these measures of stress, SROs, and AL using Bayesian structural equation models.

  3. To estimate the prevalence of stress, SROs, and AL in the general population in the U.K., using Bayesian schemes for finite population sampling.

Research Methods


Aim 1: Developing operational definitions of stress, stress-related outcomes, and allostatic load


There have been a number of scales that have been developed for the explicit purpose of assessing stress, including the Holmes and Rahe Stress Scale [17], the Daily Hassles Scale [18], and Sheldon Cohen's Perceived Stress Scale [4], and their derivatives. However, to our knowledge, these scales have not been administered to a broad sample in the U.K.. Similarly, physiological markers are often used as an objective measure of stress and as a component of allostatic load. As the hypothalamus-pituitary-adrenal (HPA) axis plays a central role in stress responses, measurements of cortisol in saliva, blood or urine provides an objective measure of stress. However, such samples are typically not taken in large scale surveys, and other objective measures of stress, for example heart rate or performance at certain tasks, while used in small experimental settings, are not feasible. Only two studies within the ESDS, the Daytracker (2007-2008) study (SN 6692 [19]) and the Social Experience of Transition to School study (SN 5654) measured cortisol. The limited scope of physiological data related to stress in publicly available U.K. retrospective data is likely to limit its utility, as well as complicating the definition of allostatic load, which typically includes physiological measures such as cholesterol levels in the blood.

Hence, we will first survey available datasets for the availability of measures of stressors, stress, stress-related outcomes, coping, and allostatic load in order to generate operational definitions of these variables that can be applied to available retrospective data. This will involve identification of common items in psychometric scales from the literature and in the available secondary data.

Measures of stressors

Many factors can in theory cause stress; in the Stress in America 2011 study [12], money, work, and the economy were the most frequently cited causes of stress, but relationships, family responsibilities, and personal and family health problems were also cited frequently (c. 50% of participants, after reweighting). To address such stressors indirectly, we will employ individuals' income; family size and composition; information related to marital relationships (such as frequency of arguing, etc.); job type, especially for professions such as healthcare, which are associated with high stress; and reports of any health problems.

Subjective measures of stress and stress-related outcomes

In contrast to the limited number of studies in ESDS that measured physiological aspects of stress, there are many studies that include items related either to perceived stress or to stress related outcomes. For example, in the National Child Development Study (NCDS), individuals are asked about perceived stress (n8scq2d, “I get stressed out easily”, on a Likert scale of 1-5), and whether stress is related to leaving a job or starting a new one because of stress. Similarly, in the widely used General Health Questionnaire (GHQ-12), individuals are also asked whether they feel relaxed, constantly under strain, and whether they have lost sleep over worry. The Short-Form 12 (SF-12) Health Survey also asks whether individuals feel 'calm and peaceful'. The Understanding Society survey, the successor to the the British Household Panel Survey, includes both GHQ-12 and SF-12 questionnaires. More generally, the widespread use of GHQ-12 and SF-12 in the literature will help to integrate results from different datasets. Surveys will be searched for these standard questionnaires, as well as for terms including 'stress', 'strain', 'anxiety', 'worry', 'loss of/lost sleep', 'calm', 'relaxed', etc., and items will be classified into negatively phrased (NP) and positively phrased (PP). We will also search for survey items that capture major life events.

To determine the extent to which the omission of physiological data affects conclusions, we will also conduct studies of U.S. data through the Interuniversity Consortium for Political and Social Research (ICPSR) (http://www.icpsr.umich.edu/). For example, there are currently 52 datasets that have measured cortisol and stress, including large studies such as the Daily Stress Project of the National Survey of Midlife in the United States (MIDUS II), the National Longitudinal Study of Adolescent Health (Add Health), the 500 Family Study and the NICHD Study of Early Child Care and Youth Development. Permission to use these data is on a case-by-case basis, with separate ethical clearance required for each study, mainly due to the need to check data security. Further details on the steps we have taken to ensure data security is outlined in the ethics section.

Coping with stress

Some level of stress is unavoidable, and individuals may expect a certain amount of stress in their levels. However, if stress is not addressed, it may progress to chronic stress, with consequences for health in the long term. Individuals may respond to stress by coping strategies, which refer to the specific efforts, both behavioral and psychological, that people employ to master, tolerate, reduce, or minimize stressful events. Coping strategies may either be problem solving, i.e. targeted at reducing stressors, or emotion focused, which involves efforts to regulate the emotional consequences of stress. An additional distinction that is often made in the coping literature is between active and avoidant coping strategies. Strategies to cope with stress include diversionary techniques, such as taking part in sports, exercise, media, eating, drinking, smoking, illicit drug use, and medication, meditation/breathing/prayer, and talking to friends or family. Some individuals may have a more passive approach to coping with stress, continuing until the stress “goes away”.

Researchers have typically used the Ways of Coping measure, originally formulated as yes/no questions [20] and subsequently revised to employ a Likert scale [21], the COPE [22], and the Coping Strategy Indicator [23] to assess coping, As these scales were not measured in the available datasets, as for other variables, we will identify common items between coping scales and the surveys. For example, the NCDS asks individuals whether they left a job due to it being too stressful, an example of an active, problem-solving coping strategy. Many surveys ask about alcohol, which is often used as an avoidant, diversionary coping strategy.

Allostatic load

There have been a number of operationalisations of allostatic load (AL), and different studies have employed different biomarkers, which fall into neuroendocrine, immune, metabolic, cardiovascular/respiratory, and anthropometric types [13]. Based on our preliminary searches, data on physiological variables is unlikely to be forthcoming, as biological samples are not normally obtained in large surveys in the U.K.. However, anthropometric measures (height, weight), as well as cardiovascular measures such as self-reported high blood pressure and heart disease, as well as reports of conditions such as diabetes are often collected e.g. in the NCDS. Some data sources may contain further information on health status, such as cholesterol. Hence, we are likely to obtain information from the U.K. on metabolic, anthropometric, and cardiovascular aspects of AL, but are likely to have sparse data on neuroendocrine and immune types. As for objective measures of stress, we will survey ICPSR for datasets that comprise all of these types, in order to understand the limitations of defining AL with a subset of types.

Aim 2: Analysis of stress, stress-related outcomes, and allostatic load

As retrospective data were not collected with the purpose of quantifying stress and allostatic load, not all variables relating to stressors, stress (either objective or perceived), SROs, or allostatic load are likely to be present in the same dataset. In addition, the way in which these phenomena are captured is also likely to be heterogeneous. For example, questions may be positively or negatively phrased, or may employ different, but related, concepts such as stress versus worry.

To capture potential causal relationships between measures of stress, SROs, and Al, we will develop structural equation models (SEMs), which can accommodate multiple variables simultaneously as predictors and outcomes. SEMs have been used to analyze stress by Willoughby et al. [24], who used latent curve models to capture cortisol dynamics in a pretest-posttest-followup of 3-5 year old childen attending 'Head Start', as well as by Cheng and Li [25], who developed an adolescent stress index that captured both major life events and hassles, and related this index to measures of physical and depressive symptoms in high school students. SEMs have also been used to model how coping strategies are related to stress [26-30] .

>

One of the problems of fitting SEMs using classical, likelihood based approaches is that a potentially large amount of data is needed, in which case model fits can be very unstable and the estimator of confidence intervals unreliable. Instead, we will fit Bayesian SEMs (BSEMs), which by making prior assumptions about parameter values (which can be vague or informative), can result in more stable model fits, and which generate a full (posterior) probability distribution of parameter estimates [31]. In addition, Bayesian approaches can be used to integrate many, potentially disparate sources of data, in what has been described as Bayesian evidence synthesis. For example, Jackson et al. [32] used Bayesian graphical model to study the association between low birth weight and air pollution in England and Wales using a combination of register, survey, and small-area aggregate data; this approach allowed them to combine these datasets, even though they comprised of different variables. Datasets that overlap, for example in their use of specific behavioral scales, are highly useful in this regard. A Bayesian approach also permits the evaluation of the consistency of evidence [33], the (at least partial) correction of ecological bias that may be introduced when covariates are pooled [34], as well as the sensitivity of the results to confounders that may not be measured directly [35].

As both stressors and stress-related outcomes (SROs) are measured in various ways, incorporation of latent states into the model may help to capture underlying variation in 'true' stress. The overall approach is not new - it is the basis of factor analysis, commonly used in psychometrics – rather, the novelty in this aim is the integration of these latent, unobserved variables into the overall statistical model, and through the approach of Bayesian evidence synthesis, integrating different ways in which studies have measured stress and SROs. In addition, by performing a joint analysis, the loadings of each measurement to the latent variables are estimated to maximise the covariation between the latent variable and the outcome, and hence a joint model is likely to provide a better fit than a model where scales are estimated a priori. For example, in an analysis of the 2007 Adult Psychiatric Morbidity Survey, Congdon [36] demonstrated that social capital, as reflected in neighbourhood perceptions, is a significant factor affecting risks of different types of self-harm through the modelling of social capital, socio-economic status, and social isolation, as latent variables that are proxied (or measured) by observed indicators or question responses for survey subjects. SEMs can incorporate response bias to positive and negative phrased items versions, through the use of other variables in the scale to control for response bias. For example, Hankins [37] analysed data from the 2004 Health Survey for England using SEMs, and concluded that GHQ-12 generated a unidimensional scale with a substantial degree of response bias for the negatively phrased items.


In contrast to standard statistical models, with a single outcome and one or more predictors, SEMs can treat variables as both an outcome and as a predictor; however, causal relationships have to be assumed between variables to fully specify a SEM. Initially, we will adopt a proximate determinants conceptual framework [38], with stressors as the ultimate cause of stress, with perceived stress, stress-related outcomes such as loss of sleep or self-reports such as 'I am stressed a lot', as intermediates, and AL as a proximate factor. We will also mine Pubmed abstracts for co-occurrences of terms related to psychosocial stress, and identify hypothesized causal relationships between these terms.

Figure 1: One model of interrelationships between stressors, stress, coping, and stress-related outcomes


One possible set of causal relationships is shown in Figure 1. Stressors are hypothesized to be related directly to perceived stress, which affects both psychological well-being and allostatic load. Avoidant coping strategies are hypothesized to affect perceived stress directly, while problem-focused coping is hypothesized to operate via the impact on stressors. Note that this represents only one hypothesis; for example, problem-focused coping may also directly affect perceived stress, independently from the effect via reduction in stressors. The model could also include other variables such as smoking and alcohol use, which would be related to both psychological well-being, avoidant coping, and allostatic load. One of the advantages of using a probabilistic framework such as BSEMs is that different models can be compared, even when the models are not nested (i.e. one is not a direct simplication of another), through the use of Bayes factors.

Aim 3: Inferring the impact of stress, SROs, and AL in the general population in the U.K.

In addition to the heterogeneity of the questions asked of participants, the sample of each study is different from each other, and from the composition of the general population as a whole. To assess the extent of stress in the U.K., we will apply finite population sampling approaches to extrapolate our results from the sample to the general population. Most commonly, a frequentist approach is taken to this problem. For example, if the mean of an auxiliary variable is known a priori in the population, then a ratio estimator can be used to calculate the population mean, using the mean of the auxiliary variable in the sample. However, in order to estimate quantities such as quantiles, or if prior information on the population other than the mean is available, more sophisticated techniques are required.

Given our Bayesian approach in Aim 2, a straightforward approach to obtain population-level information is to take our posterior distribution of estimates, and transform them into a predictive distribution. To do this, we can sample from the posterior distribution and simulate complete copies of the population, using information on auxiliary variables present in the sample for which there is prior information at the population level. To incorporate this prior information into our analysis, we will employ a constrained Polya posterior [39] , which essentially places probability mass only on predictive samples that satisfy the constraints of the auxiliary variables at the population level. We will employ nationally representative data, such as that from the U.K. Census, to generate prior information for auxiliary variables, such as age, gender, socioeconomic status, etc..

Research Outputs

We anticipate at least three research publications arising directly from this secondary analysis, including (a) a technical paper describing the challenges and opportunities for developing operational definitions relating to stress from the currently available data; (b) one or more papers describing associations between stressors, perceived stress, stress-related outcomes and allostatic load under different conceptual models of their interrelationships; and (c) a paper that describes the extent of stress and its consequences at the national level. The latter paper, especially, has the potential to stimulate discussion amongst policy makers about the problem of stress at the national level.


References cited

[1] Rosengren, A.; Hawken, S.; Ounpuu, S.; Sliwa, K.; Zubaid, M.; Almahmeed, W. A.; Blackett, K. N.; Sitthi-amorn, C.; Sato, H.; Yusuf, S. & , I. N. T. E. R. H. E. A. R. T. i. (2004). Association of psychosocial risk factors with risk of acute myocardial infarction in 11119 cases and 13648 controls from 52 countries (the INTERHEART study): case-control study., Lancet 364 : 953-962.

[2] Chida, Y.; Hamer, M.; Wardle, J. & Steptoe, A. (2008). Do stress-related psychosocial factors contribute to cancer incidence and survival?, Nat Clin Pract Oncol 5 : 466-475.

[3] Cohen, S. & Williamson, G. M. (1991). Stress and infectious disease in humans., Psychol Bull 109 : 5-24.

[4] Cohen, S.; Kamarck, T. & Mermelstein, R. (1983). A global measure of perceived stress., J Health Soc Behav 24 : 385-396.

[5] Perez, V.; Uddin, M.; Galea, S.; Monto, A. S. & Aiello, A. E. (2011). Stress, adherence to preventive measures for reducing influenza transmission and influenza-like illness., J Epidemiol Community Health .

[6] Segerstrom, S. C. & Miller, G. E. (2004). Psychological stress and the human immune system: a meta-analytic study of 30 years of inquiry., Psychol Bull 130 : 601-630.

[7] Cohen, S.; Janicki-Deverts, D.; Doyle, W. J.; Miller, G. E.; Frank, E.; Rabin, B. S. & Turner, R. B. (2012). Chronic stress, glucocorticoid receptor resistance, inflammation, and disease risk., Proc Natl Acad Sci U S A .

[8] McEwen, B. S. & Stellar, E. (1993). Stress and the individual. Mechanisms leading to disease., Arch Intern Med 153 : 2093-2101.

[9] McEwen, B. S. (2000). Allostasis and allostatic load: implications for neuropsychopharmacology., Neuropsychopharmacology 22 : 108-124.

[10] U.K. Health & Safety Executive (2012). Stress-related and psychological disorders in Great Britain (GB), .

[11] Chandola, T., 2010. Stress at Work. The British Academy, .

[12] American Psychological Association (2011). Stress in America: Our Health at Risk, .

[13] Juster, R.-P.; McEwen, B. S. & Lupien, S. J. (2010). Allostatic load biomarkers of chronic stress and impact on health and cognition., Neurosci Biobehav Rev 35 : 2-16.

[14] The Government Office for Science, London (2008). Foresight Mental Capital and Wellbeing Project, .

[15] U.K. Office for National Statistics (). Measuring Societal Well-being, .

[16] OECD, 2011. How's Life?: Measuing well-being.. OECD Publishing, .

[17] Holmes, T. H. & Rahe, R. H. (1967). The Social Readjustment Rating Scale., J Psychosom Res 11 : 213-218.

[18] Kanner, A. D.; Coyne, J. C.; Schaefer, C. & Lazarus, R. S. (1981). Comparison of two modes of stress measurement: daily hassles and uplifts versus major life events., J Behav Med 4 : 1-39.

[19] Dockray, S.; Grant, N.; Stone, A. A.; Kahneman, D.; Wardle, J. & Steptoe, A. (2010). A Comparison of Affect Ratings Obtained with Ecological Momentary Assessment and the Day Reconstruction Method., Soc Indic Res 99 : 269-283.

[20] Folkman, S. & Lazarus, R. S. (1980). An analysis of coping in a middle-aged community sample., J Health Soc Behav 21 : 219-239.

[21] Folkman, S. & Lazarus, R. S. (1985). If it changes it must be a process: study of emotion and coping during three stages of a college examination., J Pers Soc Psychol 48 : 150-170.

[22] Carver, C. S.; Scheier, M. F. & Weintraub, J. K. (1989). Assessing coping strategies: a theoretically based approach., J Pers Soc Psychol 56 : 267-283.

[23] Amirkhan, J. (1990). A factor analytically derived measure of coping: The Coping Strategy Indicator., Journal of personality and social psychology 59 : 1066.

[24] Willoughby, M.; Vandergrift, N.; Blair, C. & Granger, D. (2007). A structural equation modeling approach for the analysis of cortisol data collected using pre--post--post designs, Structural Equation Modeling 14 : 125-145.

[25] Cheng, S.-T. & Li, K.-K. (2010). Combining major life events and recurrent hassles in the assessment of stress in Chinese adolescents: preliminary evidence., Psychol Assess 22 : 532-538.

[26] Wei, M.; Heppner, P. & Mallinckrodt, B. (2003). Perceived coping as a mediator between attachment and psychological distress: A structural equation modeling approach., Journal of Counseling Psychology 50 : 438.

[27] Asberg, K. K.; Bowers, C.; Renk, K. & McKinney, C. (2008). A structural equation modeling approach to the study of stress and psychological adjustment in emerging adults., Child Psychiatry Hum Dev 39 : 481-501.

[28] Roesch, S.; Aldridge, A.; Stocking, S.; Villodas, F.; Leung, Q.; Bartley, C. & Black, L. (2010). Multilevel factor analysis and structural equation modeling of daily diary coping data: Modeling trait and state variation, Multivariate behavioral research 45 : 767-789.

[29] Wu, S.; Li, H.; Zhu, W.; Li, J. & Wang, X. (2010). A structural equation model relating work stress, coping resource, and quality of life among Chinese medical professionals., Am J Ind Med 53 : 1170-1176.

[30] Chao, R. (2011). Managing Stress and Maintaining Well-Being: Social Support, Problem-Focused Coping, and Avoidant Coping, Journal of Counseling & Development 89 : 338-348.

[31] Lee, S., 2007. Structural equation modeling: A Bayesian approach. John Wiley & Sons Inc, .

[32] Jackson, C. H.; Best, N. G. & Richardson, S. (2009). Bayesian graphical models for regression on multiple data sets with different variables., Biostatistics 10 : 335-351.

[33] Ades, A. E.; Welton, N. J.; Caldwell, D.; Price, M.; Goubar, A. & Lu, G. (2008). Multiparameter evidence synthesis in epidemiology and medical decision-making., J Health Serv Res Policy 13 Suppl 3 : 12-22.

[34] Govan, L.; Ades, A. E.; Weir, C. J.; Welton, N. J. & Langhorne, P. (2010). Controlling ecological bias in evidence synthesis of trials reporting on collapsed and overlapping covariate categories., Stat Med 29 : 1340-1356.

[35] Gustafson, P.; McCandless, L. C.; Levy, A. R. & Richardson, S. (2010). Simplified Bayesian Sensitivity Analysis for Mismeasured and Unobserved Confounders, Biometrics 66 : 1129-1137.

[36] Congdon, P. (2011). Latent variable model for suicide risk in relation to social capital and socio-economic status., Soc Psychiatry Psychiatr Epidemiol .

[37] Hankins, M. (2008). The factor structure of the twelve item General Health Questionnaire (GHQ-12): the result of negative phrasing?, Clin Pract Epidemiol Ment Health 4 : 10.

[38] Bongaarts, J. (1978). A Framework for Analyzing the Proximate Determinants of Fertility, Population and Development Review 4 : pp. 105-132.

[39] Lazar, R.; Meeden, G. & Nelson, D. (2008). A noninformative Bayesian approach to finite population sampling using auxiliary variables, Survey Methodology 34 : 51.


Creative Commons Licence
A secondary analysis of stressors, stress, and stress-related outcomes in the United Kingdom by Simon D,W, Frost is licensed under a Creative Commons Attribution 3.0 Unported License.

Wednesday, June 19, 2013

Setting up Julia

Julia is a promising new language for statistical computing. However, it's still in a relatively early stage of development. In particular, the package manager is prone to breaking, and I've had some problems getting it working smoothly, as it (currently) doesn't seem possible to remove packages. This is a problem, as if an installation doesn't work, then you can't add any more packages. While this problem will eventually be resolved, this is my setup for now, which should work on Linux and Mac OSX.

  1. I built the latest Julia from the git repository.

cd ~/Programs
git clone https://github.com/JuliaLang/julia.git
cd julia
make
  1. I added the julia build directory to my path.

export PATH=$PATH:~/Programs/julia/usr/bin

I can then launch julia as follows.


julia-release-readline

Recent builds of ESS in Emacs have some support for Julia; you'll need to add the julia binary to your .emacs file.


(load "/home/simon/Programs/ESS/lisp/ess-site") ;; or wherever ESS lives
(setq inferior-julia-program-name "/home/simon/Programs/julia/usr/bin/julia-release-basic")

Now typing M-x julia will start a Julia REPL, you can open up a Julia .jl script, and send lines or regions to the buffer.

  1. I added the following packages.


Pkg.add("DataFrames")
Pkg.add("Distributions")
Pkg.add("Winston")

When installing Winston, I've found that on OSX, installation of dependencies is best done from source; using the brew option broke the installation, and hence blocked me from adding new packages. Also, Julia has problems finding libcairo and fontconfig that I've installed using Homebrew, so these need to be added to the library path. On my machine:


export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/Cellar/Cairo/1.12.2/lib:/usr/local/Cellar/fontconfig/2.10.93/lib

You'll have to change the versions according to your setup.