Unbiased RMSE ubrmse
I am writing simple function in R to calculate the unbiased RMSE (ubrmse) given a set of observed and expected values. The function I have so far is as follows:
library(hydroGOF)
ubRMSE < function(obs, exp) {
#Combine the observed and expected data into data frame
newDf < cbind.data.frame(obs, exp)
#Remove any rows containing NA values
newDf < newDf[complete.cases(newDf), ]
#Calculate r
r < as.data.frame(gof(sim = newDf[,2], obs = newDf[,1], digit = 4))
r < r[16,1]
#Calculate ubRMSE
ubRMSEStat < sqrt(var(newDf[,2]) + var(newDf[,1])  2 * r *
var(newDf[,2]) * var(newDf[,1]))
return(ubRMSEStat)
}
Can anyone tell me if both the function and the formula for the unbiased RMSE are correct? The formula was taken from the following publication https://pubag.nal.usda.gov/download/60040/PDF. I have not come across any packages which include a formula for the unbiased RMSE (hydroGOF, tdr) although many organizations seem to use the metric.
In addition, within the paper there appears to be estimation operators. Can this simply be considered as the mean estimated soil moisture value for a given day, or does it need to consider more?
Cheers,
Matt
*Edit: Punctuation, tags, formula and added citation
See also questions close to this topic

How to randomly call a function within a given time interval ?  Python
I am creating a simulator which tries to simulate an office Door Sensor. The office is usually open from 8.00am to 6.00pm. The function would give me timestamps when the door was opened and when the door was closed ( in Timestamps ). The door takes 10 seconds to close.
So I want to create a function which I would randomly call between 8.00am to 6.00pm. That function would give me timestamps of when the door was opened and closed.
Simulator runs a loop per second , and I would want to call this function randomly between 8.00am to 6.00pm.
I'd appreciate if you can suggest me a different approach.
Thanks.

Finding the cosine similarity between rows in a data frame using only common non null columns
I want to write a function to find the cosine similarity between an index row (query) and every other row in the dataframe, by using the common columns only. The problem I face is that the common non null columns may differ between rows. I have tried replacing the values with 0's, as advised when I asked a similar question before, but this is not the output or method I am looking for so I am trying to be more specific here. For example my query is like so:
A B C D E F 1 3 Nan 2 1 Nan 4
and this is contained in the similar_rows data frame:
A B C D E F 0 2 3 Nan 3 1 Nan 1 3 Nan 2 1 Nan 4 2 Nan 4 1 3 Nan 5
Therefore the cosine similarity should be found between the query (which in this case is index 1) and both 0 and 2 separately using only their non null common columns. So the cosine similarity between 0 and 1 should be found using only columns A and D as they are both non null.
My function so far looks like this:
def sims(index): #find_similar_times finds all times within a minutes threshold of the index row, not necessary to know that for this question but just giving some context similar_rows = find_similar_rows(index) #finding the columns of the query query_cols = similar_rows.loc[index] #getting them columns as a list after finding only non null columns of the query q_cols_names = query_cols[query_cols.notnull()] q_cols_names = list(q_cols_names.index) #putting the query into it's own dataframe qs = pd.DataFrame(query_cols[q_cols_names]) qs = qs.T #this is where the error occurs. I am not sure why result = similar_rows[q_cols_names].apply(lambda row: cosine(row, query_cols[q_cols_names])) return result
This is a complicated problem to explain so apologies in advance if it is not clear. Any help is greatly appreciated.

C: It is possible to pass variables to a function that request a struct so when the function is called these variables are wrapped into a struct?
I have a function that request a struct.
struct test{ const int a; const int b; }; void testFunction(struct test mytest) { //code }
I was wondering if there is a way of passing two ints to the function so the process of calling it wraps those two ints into a struct.
Something like:
void main() { //function call with some sort of wrapping system... testFunction({1,2}); }
Is there a way to the {1,2} wrapping part?
(If there is... Could be also done with functions that request pointer to structs?)
Thanks in advance,
Juan

This question has been creating confusion among me and my classmates. What would be the appropriate answer?
Everybody is saying its option 3, but my doubt is, isnt option 4 the correct answer? Help me with this.
Q.) 70% people like coffee, and 64% people like tea. How many people (x%) like both? Options) a) x >= 34 b) x <= 64 c) 34 <= x <= 64 d) all of these.

Scale/Radius ratio issue
I have a scale variable and a radius variable. When scale is a specific number, ratio needs to be a specific number. So far I know this..
Scale = 0.25 and Radius = 3.00 Scale = 0.50 and Radius = 1.50 Scale = 0.75 and Radius = 1.00 Scale = 1.00 and Radius = 0.75
I need to find out what number the radius should be for 0.10, 0.15, 0.20, etc all the way to 1.0 and I can't figure out how. Does anyone have any ideas?

Attempting to simplify a quadruple system
I am attempting to simplify a horribly complicated equation that can be expressed in the form
$\frac{ay^2}{(b(xc))^d)}=z$.
By plugging in x and y values I am able to find points to set up a system of equations to solve for a, b, c, and d. Simplifying the original equation via normal methods is not viable. Some points on the function:(0,25,30.8493);(0,50,123.3972);(0.75,100,18.2265);(0.75,125,28.4790);(1,75,2.5545);(1,125,7.0588); (1,25,0.2838).
I have tried simplifying many times, most of which ended up in
$0=1$
, however, I have had one successful attempt, which resulted in$d=\frac{ln{\frac{z_1}{z_2}}}{ln{\frac{1c}{c}}}$
, where$z_1$
is the zvalue of(0,25,30.8493)
and$z_2$
is the zvalue of(1,25,0.2838)
.Therefore I now have a triple system, but one that seems almost unsimplifiable algebraically, at least at my level. I don't have access to graphing software capable of solving this graphically. This is a physics model, so I know that by physical constraints that
$a$, $b$,
and$d$
must be positive, and$c$
must be a negative number greater than 2. 
Positive and negative correlation in linear regression
Can we use Linear regression for a problem where one variable is positively correlated and the other variable is negatively correlated? For example, I am trying to predict the wage of a football player and the variables are Overall rating and age. As age increases, wage decreases but, as overall rating increases, the wage increases.
Can I apply Linear regression on this? as in y=overallx1+agex1+c

What is the best way to assign a risk score to credit customers
I need to assign a risk score to credit customers. I have a history of ontime and late payments on credit accounts. I need to present a report that shows how risky a customer is based on their past history. My data looks like:
cust_id  acct_type  statement_date  payment_date  late  123 cc 20160230 20160228 0 123 loan 20161127 20161201 1 123 cc 20160127 20160201 1 134 loan 20160130 20160131 1 776 cc 20160601 20160523 0
I want to assign a score per account type (acct_type). In the above example, customer 123 made one ontime payment but made two late payments. I don't think the average is enough. Somehow I need to find a way to score based on how well they are doing now based on history. For example, a couple of missed payments in 2015 shouldn't hold too much weight if they have not missed any payments in 2016.
Any suggestions would be welcomed.

Sub or function not defined: VBA code to build sample pool
Below is VBA code that is meant to generate a random sample pool. Yet before I can get to any of that I'm getting the error "Sub or function not defined" on the first line of code.
What I've found so far.  I don't believe it is an error involving a function as when I step through the code it stops on the first line.  I've activated the solver plugin as recommended Here but from what I can tell it doesn't relate to my issue.
Forgive me if I am somehow not following best practices for posting on this site. If I am making an error please let me know.
Option Explicit Sub Sample() Dim oWS As Worksheet, iRow As Long, oRange As Range, oChart As Chart iRow = InputBox("How many rows on a new sheet?", , 25) + 2 Set oWS = Worksheets.Add(, ActiveSheet) Range(Cells(2, 2), Cells(2, 11)).Formula = "=INT(Rand()*11)" Range(Cells(2, 2), Cells(2, 11)).Interior.Color = vbYellow Cells(2, 13).Formula = "=STDEV(b2:k2)" Range(Range("A2"), Cells(iRow, 11)).Table , Range("A1") Set oRange = Range(Cells(iRow + 2, 2), Cells(iRow + 2, 11)) oRange.FormulaR1C1 = "=AVERAGE(R[2]C:R[" & iRow & "]C)" oRange.Interior.Color = vbYellow Cells(iRow + 2, 13).FormulaR1C1 = "=STDEV(RC[11]:RC[2])" Range("O2:O11").Formula = "=ROW(A1)" Range("P2:P11").FormulaArray = "=FREQUENCY(B2:K2,O2:O11)" Range("O14:O23") = "=ROW(A1)" Range("P14:P23").FormulaArray = "=FREQUENCY(" & oRange.Address & ",O14:O23)" Range("O2:P11").Select oWS.Shapes.AddChart2(240, xlXYScatterLines).Select ActiveChart.SetSourceData = oWS.Range("O2:P11") ActiveChart.HasTitle = False oWS.ChartObjects(1).Top = Range("R2").Top oWS.ChartObjects(1).Left = Range("R2").Left oWS.ChartObjects(1).Width = 300 oWS.ChartObjects(1).Height = 150 Range("O14:P23").Select oWS.Shapes.AddChart2(240, xlXYScatterLines).Select ActiveChart.SetSourceData = oWS.Range("O14:P23") ActiveChart.HasTitle = False oWS.ChartObjects(2).Top = Range("R14").Top oWS.ChartObjects(2).Left = Range("R14").Left oWS.ChartObjects(2).Width = 300 oWS.ChartObjects(2).Height = 150 Range("A1").Select End Sub

CauchyBinet equation for matrices in R
I am trying to write code for the inner product determinant equation but I am a little stuck with one of the given formulas (CauchyBinet formula). [
Is there a package or function for calculating the CauchyBinet equation?

Excel formula to display horizontal list in vertical way
I have formula to display horizontal list with data in vertical order. The problem is that current formula inputs value every second cell when copied vertically. What is wrong?
P.S. Horizontal list should be as it is = every second column has number.
=IFERROR(VALUE(INDEX($1:$1;(ROW(1:1)1)+5)&"");"") < E5 =IFERROR(VALUE(INDEX($1:$1;(ROW(2:2)1)+5)&"");"") < E6 =IFERROR(VALUE(INDEX($1:$1;(ROW(3:3)1)+5)&"");"") < E7 =IFERROR(VALUE(INDEX($1:$1;(ROW(4:4)1)+5)&"");"") < E8 =IFERROR(VALUE(INDEX($1:$1;(ROW(5:5)1)+5)&"");"") < E9 =IFERROR(VALUE(INDEX($1:$1;(ROW(6:6)1)+5)&"");"") < E10 etc...

Hide zero (0) values in INDEX formula
This is the followup question to (Excel formula to transpose horizontal values in vertical list). I have formula to display horizontally placed values in vertical table.
=INDEX($1:$1;(ROW(1:1)1)*2+4) =INDEX($1:$1;(ROW(2:2)1)*2+4) etc
The problem with current solution is that it is displaying (0) zero values if cells are empty. How I can modify this formula to hide all zero (0) values so it will give as a result
""
In one column I have numbers and in other one text. So solution should be suitable for both or optionally two different approaches I can input to two different columns.
P.S. I do not want to hide zero values by Excel options, because I will use values further on and need them to be
=""

Is there rest api to get R language packages details or CRAN packages details
I'm building a database from CRAN/ R language packages. Is there rest api for getting packages details  for example testthat package https://cran.rproject.org/package=testthat

Possibility of using multiple CRAN mirrors? [RStudio]
I've spent the last 4 hours trying to find out why I wasn't able to install any packages in
R
(it started with me trying to install a package I was developing). It would just stall for +5 minutes without doing anything or outputting anything to the terminal. I tracked the issue down to the following call:repos < structure("https://cran.rstudio.com/", .Names = "CRAN") type < "both" utils::available.packages(utils::contrib.url(repos, type), type = type)
I realized after a while that it was just the RStudio CRAN mirror, and when I changed the repo to "https://cran.case.edu/", it started working. However, there was literally no indication of this on the surfaceand it took forever for me to find out what the problem was.
My question is this: Is there a way of using multiple CRAN repos so when one fails, others are used? Or at least a way that will prevent this from happening again?

getting lazy data or active binding without attaching package
Background:
I have a CRAN R package which has a dependency on lazyloaded data in another CRAN package of a specific version. I need to avoid using
::
to refer to the data, because it causes CRAN check to fail.I've read: Evaluate function within package environment without attaching package and See if a variable/function exists in a package?
I've tried (using nycflights13 for this example):
# this works, but I can't use :: nycflights13::airlines find("airlines") # character(0) get("airlines", envir = asNamespace("nycflights13"), mode = "list") #Error in get("airlines", envir = asNamespace("nycflights13"), mode = "list") : object 'airlines' of mode 'list' was not found # attach library(nycflights13) get("airlines", envir = asNamespace("nycflights13"), mode = "list") # works find("airlines") # [1] "package:nycflights13"
This may make it even more complicated, but I actually want to refer to an active binding, which returns data which may or may not be available.
What I would like:
A CRAN compatible way of referring to lazyloaded data in another package without using
::
or Imports in DESCRIPTION.