Unable to label my significant correlation on the corrplot - r-corrplot

So I am trying to plot a corrplot. The code I am using is
corrplot::corrplot(cor.Phenotyping.All.scaled$r, type = "full", diag = TRUE,
method = "color", tl.cex = 0.4, tl.col = 'black', outline = F,
order = "original", p.mat = NULL,
pch.col = "white", sig.level = c(.001), pch.cex = .5 , insig = "label_sig",
col = colorRampPalette(c("darkred","white","midnightblue"))(100),
cl.pos = "b")
The code does make a plot but the significant correlations are not labelled as asterisk in the plot. My significant value is p<0.001 and significant correlations are present in my data. I have tried multiple ways i have tried extracting significant p-values and putting them to make a graph using but still I cannot get asterisk. Desperate for help

Related

How to spatially plot an attribute parameter?

Here is my code below. I want to plot CO2 distribution over the South African map.
Loading packages
library(tidyverse)
theme_set(theme_bw())
library("sf")
library("rnaturalearth")
library("rnaturalearthdata")
Assigning world to the countries of the world data
world <- ne_countries(scale = "medium", returnclass = "sf")
Reading the local file with CO2 and geographic coordinates (Lon and Lat)
SA_CO2 <- read_csv2("C:/Users/Xolile Ncipha/Documents/SA_CO2_DJF_2004_2009.csv")
Converting the data frame to a sf object and the coordinate reference system projection to WGS84, which is the CRS code #4326.
(SA_CO2 <- st_as_sf(SA_CO2, coords = c("Lon", "Lat"), crs = 4326, agr = "constant"))
Plotting the map and overlaying it with CO2 dataThe output of my code/script.
ggplot(data = world) + geom_sf() + geom_sf(data = SA_CO2, aes(fill = CO2)) +
CO2 legend
scale_fill_gradientn(colors = sf.colors(10)) +
Confining the map to South African domain.
coord_sf(xlim = c(15, 35), ylim = c(-36, -22.3), expand = FALSE) +
Axis labels
xlab("Longitude") + ylab("Latitude")
The results is the geographic points on the map. I don't get the overlay of CO2 data and its spatial distribution. I have attached a picture of the resulting map and the spatial data.
This is a good question. But, unfortunately, you did not provide a link to the source of your data ( "SA_CO2_DJF_2004_2009.csv"), so it was necessary for me to create some data that is likely somewhat similar to your data, but probably not exactly the same.
I found a spelling error in the following line of your code. Even after correcting the spelling error, this line of code continued causing an error.
scale_fill_gradientn(colors = sf.colors(10)) +
The data I used included tons of CO2 from SA during the years, 2010-2016. I also selected a few SA cities with populations from another source, and then allocated the SA annual CO2 by the ratio of the combined city populations. Therefore, those cities with smaller populations were allocated smaller proportions of the annual CO2 and the larger cities were allocated larger ratio's of CO2.
https://howsouthafrica.com/major-cities-international-airports-south-africa/
https://data.worldbank.org/indicator/EN.ATM.CO2E.KT?locations=ZA&view=map
The code used to create the plot shown at the link below is:
ggplot(data = world) +
geom_sf() +
geom_sf(data = coor.sf, aes(size = tons),
fill = "blue", color = "blue", alpha = .3) +
coord_sf(xlim = c(15, 35), ylim = c(-36, -22.3),
expand = FALSE) + xlab("Longitude") + ylab("Latitude")
Please email me if you have any questions.
[[![SA CO2]]

Standard Deviation only using daily values to show on every time chart in Pine Script

I am trying to make a Standard Deviation overlay using only the daily inputs, and have it overlay that info on any time frame chart. So, even if I look at an hourly chart, I will still see the daily deviations overlayed on the chart. I made one that changes with whatever time frame I am looking at. I started with another public one to make this:
study(title="Standard Deviation",shorttitle="SD",overlay=true)
length = input(20, minval=1)
src = input(open, title="Source")
sd = stdev(src, length)
piv=open
plotOpen = plot(piv,title="Open",color=black,trackprice=true,linewidth=2)
plotR05 = plot(piv+(0.5*sd),title="+0.5", color=red,trackprice=true,linewidth=2)
plotS05 = plot(piv-(0.5*sd),title="-0.5", color=red,trackprice=true,linewidth=2)
plotR10 = plot(piv+sd,title="1", color=blue,trackprice=true,linewidth=2)
plotS10 = plot(piv-sd,title="-1", color=blue,trackprice=true,linewidth=2)
plotR15 = plot(piv+(1.5*sd),title="+1.5", color=green,trackprice=true,linewidth=2)
plotS15 = plot(piv-(1.5*sd),title="-1.5", color=green,trackprice=true,linewidth=2)
plotR20 = plot(piv+(2*sd),title="+2", color=orange,trackprice=true,linewidth=2)
plotS20 = plot(piv-(2*sd),title="-2", color=orange,trackprice=true,linewidth=2)
I am trying to make a Standard Deviation overlay using only the daily inputs, and have it overlay that info on any time frame chart.
You can use TradingView's security() function for that. That function can load price data from any time frame and/or instrument, including the daily data from the current instrument.
With security() your code can thus calculate the daily standard deviation regardless of which time frame the script currently runs on.
For example:
study(title="Standard Deviation",shorttitle="SD",overlay=true)
length = input(20, minval=1)
src = input(open, title="Source")
// Load daily stddev
dailyStd = security(tickerid, "D", stddev(src, length))
piv=open
plotOpen = plot(piv,title="Open",color=black,trackprice=true,linewidth=2)
plotR05 = plot(piv+(0.5*dailyStd),title="+0.5", color=red,trackprice=true,linewidth=2)
plotS05 = plot(piv-(0.5*dailyStd),title="-0.5", color=red,trackprice=true,linewidth=2)
plotR10 = plot(piv+dailyStd,title="1", color=blue,trackprice=true,linewidth=2)
plotS10 = plot(piv-dailyStd,title="-1", color=blue,trackprice=true,linewidth=2)
plotR15 = plot(piv+(1.5*dailyStd),title="+1.5", color=green,trackprice=true,linewidth=2)
plotS15 = plot(piv-(1.5*dailyStd),title="-1.5", color=green,trackprice=true,linewidth=2)
plotR20 = plot(piv+(2*dailyStd),title="+2", color=orange,trackprice=true,linewidth=2)
plotS20 = plot(piv-(2*dailyStd),title="-2", color=orange,trackprice=true,linewidth=2)
Give it a try to see if this approach better serves your goal.
for version 5
//#version=5
indicator("Standart Deviation", shorttitle="SD", overlay=true)
length = input.int(30, minval=1)
src = input.source(open,"Source")
//load daily stdev
dailyStd = request.security(syminfo.tickerid,"D",ta.stdev(src,length))
piv=open
plotOpen = plot(piv,title="Open", color=color.white, trackprice = true, linewidth=2)
plotStdResistance = plot(piv+dailyStd,title="RESISTANCE",color=color.red,trackprice=true,linewidth=1)
plotStdSupport = plot(piv-dailyStd,title="SUPPORT", color=color.green, trackprice = true, linewidth=1)

Color Scale color for Highcharter maps

I have made a plot of France displaying some values accross departments.
My problem its that I have negative values And Ill like to start the color scale from red to blue (or green), a way to fix it?
Here is my code
hcmap("countries/fr/fr-all-all", data = freq_dept, value = "freq",
joinBy = c("name", "departmentName"), name = "Fake data",
dataLabels = list(enabled = TRUE, format = '{point.name}'),
borderColor = "#FF0000", borderWidth = 0.1) %>%
hc_mapNavigation(enabled = TRUE)

How to estimate? "simple" Nonlinear Regression + Parameter Constraints + AR residuals

I am new to this site so please bear with me. I want to
the nonlinear model as shown in the link: https://i.stack.imgur.com/cNpWt.png by imposing constraints on the parameters a>0 and b>0 and gamma1 in [0,1].
In the nonlinear model [1] independent variable is x(t) and dependent are R(t), F(t) and ΞΎ(t) is the error term.
An example of the dataset can be shown here: https://i.stack.imgur.com/2Vf0j.png 68 rows of time series
To estimate the nonlinear regression I use the nls() function with no problem as shown below:
NLM1 = nls(**Xt ~ (aRt-bFt)/(1-gamma1*Rt), start = list(a = 10, b = 10, lamda = 0.5)**,algorithm = "port", lower=c(0,0,0),upper=c(Inf,Inf,1),data = temp2)
I want to estimate NLM1 with allowing for also an AR(1) on the residuals.
Basically I want the same procedure as we go from lm() to gls(). My problem is that in the gnls() function I dont know how to put contraints for the model parameters a, b, gamma1 and the model estimates wrong values for them.
nls() has the option for lower and upper bounds. I cant do the same on gnls()
In the gnls(): I need to add the contraints something like as in nls() lower=c(0,0,0),upper=c(Inf,Inf,1)
NLM1_AR1 = gnls( model = Xt ~ (aRt-bFt)/(1-gamma1*Rt), data = temp2, start = list(a =13, b = 10, lamda = 0.5),correlation = corARMA(p = 1))
Does any1 know the solution on how to do it?
Thank you

open flash chart rails x-axis issue

I am using open flash chart 2 (the plugin) in my rails application. Everything is looking smooth except for the range on my x axis. I am creating a line to represent cell phone plan cost over a specific amount of usage and I'm generate 8 values, 1-5 are below the allowed usage while 6-8 are demonstrations of the cost for usage over the limit.
The problem I'm encountering is how to set the range of the X axis in ruby on rails to something specific to the data. Right now the values being displayed are the indexes of the array that I'm giving. When I try to hand a hash to the values the chart doesn't even load at all.
So basically I need help getting a way to set the data for my line properly so that it displays correctly, right now it is treating every value as if it represents the x value of the index of the array.
Here is a screen shot which may be a better description than what I am saying: http://i163.photobucket.com/albums/t286/Xeno56/Screenshot.png Note that those values are correct just the range on the x-axis is incorrect, it should be something like 100, 200, 300, 400, 500, 600, 700
Code:
y = YAxis.new
y.set_range(0,100, 20)
x_legend = XLegend.new("Usage")
x_legend.set_style('{font-size: 20px; color: #778877}')
y_legend = YLegend.new("Cost")
y_legend.set_style('{font-size: 20px; color: #770077}')
chart =OpenFlashChart.new
chart.set_x_legend(x_legend)
chart.set_y_legend(y_legend)
chart.y_axis = y
line = Line.new
line.text = plan.name
line.width = 2
line.color = '#006633'
line.dot_size = 2
line.values = generate_data(plan)
chart.add_element(line)
def generate_data(plan)
values = []
#generate below threshold numbers
5.times do |x|
usage = plan.usage / 5 * x
cost = plan.cost
values << cost
end
#generate above threshold numbers
3.times do |x|
usage = plan.usage + ((plan.usage / 5) * x)
cost = plan.cost + (usage * plan.overage)
values << cost
end
return values
end
Also the other problem I'm having is I can't just add a few points as any values I give are taken as x being the elements position in the array and y being the value, whereas I need to be able to specify the x and y values for each point so I don't have to buffer my array with a bunch of null values
You have to create an XAxis Object to set the labels:
x = XAxis.new
x.labels = [100, 200, 300, 400, 500, 600, 700].collect(&:to_s)
chart.x_axis = x
From my experience there are many ways to do things with Open Flash Chart 2. mikezter example above is almost correct; however, this is how I set the XAxis labels.
x = XAxis.new
x.set_labels([100, 200, 300, 400, etc]).collect(&:to_s)
chart.x_axis = x
Note the only difference between my example and mikezter's is I use:
x.set_labels([array values etc])
instead of
x.labels = [array values etc]
I ended up ditching open flash chart 2 and going with Flotr

Resources